@@ -36,103 +36,103 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class doc_generic_odt extends ModeleThirdPartyDoc |
38 | 38 | { |
39 | - /** |
|
40 | - * Issuer |
|
41 | - * @var Societe |
|
42 | - */ |
|
43 | - public $emetteur; |
|
39 | + /** |
|
40 | + * Issuer |
|
41 | + * @var Societe |
|
42 | + */ |
|
43 | + public $emetteur; |
|
44 | 44 | |
45 | - /** |
|
45 | + /** |
|
46 | 46 | * @var array() Minimum version of PHP required by module. |
47 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
47 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
48 | 48 | */ |
49 | - public $phpmin = array(5, 4); |
|
49 | + public $phpmin = array(5, 4); |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Constructor |
|
54 | - * |
|
55 | - * @param DoliDB $db Database handler |
|
56 | - */ |
|
57 | - function __construct($db) |
|
58 | - { |
|
59 | - global $conf, $langs, $mysoc; |
|
52 | + /** |
|
53 | + * Constructor |
|
54 | + * |
|
55 | + * @param DoliDB $db Database handler |
|
56 | + */ |
|
57 | + function __construct($db) |
|
58 | + { |
|
59 | + global $conf, $langs, $mysoc; |
|
60 | 60 | |
61 | - // Load translation files required by the page |
|
61 | + // Load translation files required by the page |
|
62 | 62 | $langs->loadLangs(array("main","companies")); |
63 | 63 | |
64 | - $this->db = $db; |
|
65 | - $this->name = "ODT templates"; |
|
66 | - $this->description = $langs->trans("DocumentModelOdt"); |
|
67 | - $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
68 | - |
|
69 | - // Dimension page pour format A4 |
|
70 | - $this->type = 'odt'; |
|
71 | - $this->page_largeur = 0; |
|
72 | - $this->page_hauteur = 0; |
|
73 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
74 | - $this->marge_gauche=0; |
|
75 | - $this->marge_droite=0; |
|
76 | - $this->marge_haute=0; |
|
77 | - $this->marge_basse=0; |
|
78 | - |
|
79 | - $this->option_logo = 1; // Affiche logo |
|
80 | - |
|
81 | - // Recupere emmetteur |
|
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Return description of a module |
|
89 | - * |
|
90 | - * @param Translate $langs Object language |
|
91 | - * @return string Description |
|
92 | - */ |
|
93 | - function info($langs) |
|
94 | - { |
|
95 | - global $conf,$langs; |
|
96 | - |
|
97 | - // Load traductions files requiredby by page |
|
98 | - $langs->loadLangs(array("companies", "errors")); |
|
99 | - |
|
100 | - $form = new Form($this->db); |
|
101 | - |
|
102 | - $texte = $this->description.".<br>\n"; |
|
103 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
104 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
105 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
106 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">'; |
|
107 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
108 | - |
|
109 | - // List of directories area |
|
110 | - $texte.= '<tr><td>'; |
|
111 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
112 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); |
|
113 | - $listoffiles=array(); |
|
114 | - foreach($listofdir as $key=>$tmpdir) |
|
115 | - { |
|
116 | - $tmpdir=trim($tmpdir); |
|
117 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
118 | - if (! $tmpdir) { unset($listofdir[$key]); continue; } |
|
119 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
120 | - else |
|
121 | - { |
|
122 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment |
|
123 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
124 | - } |
|
125 | - } |
|
126 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
127 | - // Add list of substitution keys |
|
128 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
129 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
130 | - |
|
131 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
64 | + $this->db = $db; |
|
65 | + $this->name = "ODT templates"; |
|
66 | + $this->description = $langs->trans("DocumentModelOdt"); |
|
67 | + $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
68 | + |
|
69 | + // Dimension page pour format A4 |
|
70 | + $this->type = 'odt'; |
|
71 | + $this->page_largeur = 0; |
|
72 | + $this->page_hauteur = 0; |
|
73 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
74 | + $this->marge_gauche=0; |
|
75 | + $this->marge_droite=0; |
|
76 | + $this->marge_haute=0; |
|
77 | + $this->marge_basse=0; |
|
78 | + |
|
79 | + $this->option_logo = 1; // Affiche logo |
|
80 | + |
|
81 | + // Recupere emmetteur |
|
82 | + $this->emetteur=$mysoc; |
|
83 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Return description of a module |
|
89 | + * |
|
90 | + * @param Translate $langs Object language |
|
91 | + * @return string Description |
|
92 | + */ |
|
93 | + function info($langs) |
|
94 | + { |
|
95 | + global $conf,$langs; |
|
96 | + |
|
97 | + // Load traductions files requiredby by page |
|
98 | + $langs->loadLangs(array("companies", "errors")); |
|
99 | + |
|
100 | + $form = new Form($this->db); |
|
101 | + |
|
102 | + $texte = $this->description.".<br>\n"; |
|
103 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
104 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
105 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
106 | + $texte.= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">'; |
|
107 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
108 | + |
|
109 | + // List of directories area |
|
110 | + $texte.= '<tr><td>'; |
|
111 | + $texttitle=$langs->trans("ListOfDirectories"); |
|
112 | + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); |
|
113 | + $listoffiles=array(); |
|
114 | + foreach($listofdir as $key=>$tmpdir) |
|
115 | + { |
|
116 | + $tmpdir=trim($tmpdir); |
|
117 | + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
118 | + if (! $tmpdir) { unset($listofdir[$key]); continue; } |
|
119 | + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
120 | + else |
|
121 | + { |
|
122 | + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment |
|
123 | + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
124 | + } |
|
125 | + } |
|
126 | + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
127 | + // Add list of substitution keys |
|
128 | + $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
129 | + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
130 | + |
|
131 | + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
132 | 132 | $texte.= '<table><tr><td>'; |
133 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
134 | - $texte.=$conf->global->COMPANY_ADDON_PDF_ODT_PATH; |
|
135 | - $texte.= '</textarea>'; |
|
133 | + $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
134 | + $texte.=$conf->global->COMPANY_ADDON_PDF_ODT_PATH; |
|
135 | + $texte.= '</textarea>'; |
|
136 | 136 | $texte.= '</td>'; |
137 | 137 | $texte.= '<td align="center"> '; |
138 | 138 | $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
@@ -140,62 +140,62 @@ discard block |
||
140 | 140 | $texte.= '</tr>'; |
141 | 141 | $texte.= '</table>'; |
142 | 142 | |
143 | - // Scan directories |
|
144 | - $nbofiles=count($listoffiles); |
|
145 | - if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) |
|
146 | - { |
|
147 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | - //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | - $texte.=$nbofiles; |
|
150 | - //$texte.=$nbofiles?'</a>':''; |
|
151 | - $texte.='</b>'; |
|
152 | - } |
|
153 | - |
|
154 | - if ($nbofiles) |
|
155 | - { |
|
156 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
157 | - foreach($listoffiles as $file) |
|
158 | - { |
|
143 | + // Scan directories |
|
144 | + $nbofiles=count($listoffiles); |
|
145 | + if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) |
|
146 | + { |
|
147 | + $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | + //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
149 | + $texte.=$nbofiles; |
|
150 | + //$texte.=$nbofiles?'</a>':''; |
|
151 | + $texte.='</b>'; |
|
152 | + } |
|
153 | + |
|
154 | + if ($nbofiles) |
|
155 | + { |
|
156 | + $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
157 | + foreach($listoffiles as $file) |
|
158 | + { |
|
159 | 159 | $texte.=$file['name'].'<br>'; |
160 | - } |
|
161 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
162 | - } |
|
160 | + } |
|
161 | + $texte.='<div id="div_'.get_class($this).'">'; |
|
162 | + } |
|
163 | 163 | |
164 | - $texte.= '</td>'; |
|
164 | + $texte.= '</td>'; |
|
165 | 165 | |
166 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
167 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
168 | - $texte.= '</td>'; |
|
169 | - $texte.= '</tr>'; |
|
166 | + $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
167 | + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
168 | + $texte.= '</td>'; |
|
169 | + $texte.= '</tr>'; |
|
170 | 170 | |
171 | - $texte.= '</table>'; |
|
172 | - $texte.= '</form>'; |
|
171 | + $texte.= '</table>'; |
|
172 | + $texte.= '</form>'; |
|
173 | 173 | |
174 | - return $texte; |
|
175 | - } |
|
174 | + return $texte; |
|
175 | + } |
|
176 | 176 | |
177 | 177 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
178 | - /** |
|
179 | - * Function to build a document on disk using the generic odt module. |
|
180 | - * |
|
181 | - * @param Societe $object Object source to build document |
|
182 | - * @param Translate $outputlangs Lang output object |
|
183 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
178 | + /** |
|
179 | + * Function to build a document on disk using the generic odt module. |
|
180 | + * |
|
181 | + * @param Societe $object Object source to build document |
|
182 | + * @param Translate $outputlangs Lang output object |
|
183 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
184 | 184 | * @param int $hidedetails Do not show line details |
185 | 185 | * @param int $hidedesc Do not show desc |
186 | 186 | * @param int $hideref Do not show ref |
187 | - * @return int 1 if OK, <=0 if KO |
|
188 | - */ |
|
189 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
190 | - { |
|
187 | + * @return int 1 if OK, <=0 if KO |
|
188 | + */ |
|
189 | + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
190 | + { |
|
191 | 191 | // phpcs:enable |
192 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | + global $user,$langs,$conf,$mysoc,$hookmanager; |
|
193 | 193 | |
194 | - if (empty($srctemplatepath)) |
|
195 | - { |
|
196 | - dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
197 | - return -1; |
|
198 | - } |
|
194 | + if (empty($srctemplatepath)) |
|
195 | + { |
|
196 | + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
197 | + return -1; |
|
198 | + } |
|
199 | 199 | |
200 | 200 | // Add odtgeneration hook |
201 | 201 | if (! is_object($hookmanager)) |
@@ -206,82 +206,82 @@ discard block |
||
206 | 206 | $hookmanager->initHooks(array('odtgeneration')); |
207 | 207 | global $action; |
208 | 208 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
210 | - $sav_charset_output=$outputlangs->charset_output; |
|
211 | - $outputlangs->charset_output='UTF-8'; |
|
212 | - |
|
213 | - // Load translation files required by the page |
|
214 | - $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
215 | - |
|
216 | - if ($conf->societe->multidir_output[$object->entity]) |
|
217 | - { |
|
218 | - $dir = $conf->societe->multidir_output[$object->entity]; |
|
219 | - $objectref = dol_sanitizeFileName($object->id); |
|
220 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
221 | - |
|
222 | - if (! file_exists($dir)) |
|
223 | - { |
|
224 | - if (dol_mkdir($dir) < 0) |
|
225 | - { |
|
226 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
227 | - return -1; |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - if (file_exists($dir)) |
|
232 | - { |
|
233 | - //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
234 | - $newfile=basename($srctemplatepath); |
|
235 | - $newfiletmp=preg_replace('/\.od(s|t)/i','',$newfile); |
|
236 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
237 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
238 | - // Get extension (ods or odt) |
|
239 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
240 | - if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) |
|
241 | - { |
|
242 | - $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; |
|
243 | - } |
|
244 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
245 | - { |
|
246 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
247 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
248 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
249 | - } |
|
250 | - else |
|
251 | - { |
|
252 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
253 | - } |
|
254 | - $file=$dir.'/'.$filename; |
|
255 | - $object->builddoc_filename=$filename; // For triggers |
|
256 | - //print "newfileformat=".$newfileformat; |
|
257 | - //print "newdir=".$dir; |
|
258 | - //print "newfile=".$newfile; |
|
259 | - //print "file=".$file; |
|
260 | - //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
261 | - //exit; |
|
262 | - |
|
263 | - dol_mkdir($conf->societe->multidir_temp[$object->entity]); |
|
264 | - |
|
265 | - // Open and load template |
|
266 | - require_once ODTPHP_PATH.'odf.php'; |
|
267 | - try { |
|
268 | - $odfHandler = new odf( |
|
269 | - $srctemplatepath, |
|
270 | - array( |
|
271 | - 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], |
|
272 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
273 | - 'DELIMITER_LEFT' => '{', |
|
274 | - 'DELIMITER_RIGHT' => '}' |
|
275 | - ) |
|
276 | - ); |
|
277 | - } |
|
278 | - catch(Exception $e) |
|
279 | - { |
|
280 | - $this->error=$e->getMessage(); |
|
281 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
282 | - return -1; |
|
283 | - } |
|
284 | - //print $odfHandler->__toString()."\n"; |
|
209 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
210 | + $sav_charset_output=$outputlangs->charset_output; |
|
211 | + $outputlangs->charset_output='UTF-8'; |
|
212 | + |
|
213 | + // Load translation files required by the page |
|
214 | + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
215 | + |
|
216 | + if ($conf->societe->multidir_output[$object->entity]) |
|
217 | + { |
|
218 | + $dir = $conf->societe->multidir_output[$object->entity]; |
|
219 | + $objectref = dol_sanitizeFileName($object->id); |
|
220 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
221 | + |
|
222 | + if (! file_exists($dir)) |
|
223 | + { |
|
224 | + if (dol_mkdir($dir) < 0) |
|
225 | + { |
|
226 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
227 | + return -1; |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + if (file_exists($dir)) |
|
232 | + { |
|
233 | + //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
234 | + $newfile=basename($srctemplatepath); |
|
235 | + $newfiletmp=preg_replace('/\.od(s|t)/i','',$newfile); |
|
236 | + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
237 | + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
238 | + // Get extension (ods or odt) |
|
239 | + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
240 | + if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) |
|
241 | + { |
|
242 | + $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; |
|
243 | + } |
|
244 | + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
245 | + { |
|
246 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
247 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
248 | + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
249 | + } |
|
250 | + else |
|
251 | + { |
|
252 | + $filename=$newfiletmp.'.'.$newfileformat; |
|
253 | + } |
|
254 | + $file=$dir.'/'.$filename; |
|
255 | + $object->builddoc_filename=$filename; // For triggers |
|
256 | + //print "newfileformat=".$newfileformat; |
|
257 | + //print "newdir=".$dir; |
|
258 | + //print "newfile=".$newfile; |
|
259 | + //print "file=".$file; |
|
260 | + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
261 | + //exit; |
|
262 | + |
|
263 | + dol_mkdir($conf->societe->multidir_temp[$object->entity]); |
|
264 | + |
|
265 | + // Open and load template |
|
266 | + require_once ODTPHP_PATH.'odf.php'; |
|
267 | + try { |
|
268 | + $odfHandler = new odf( |
|
269 | + $srctemplatepath, |
|
270 | + array( |
|
271 | + 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], |
|
272 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
273 | + 'DELIMITER_LEFT' => '{', |
|
274 | + 'DELIMITER_RIGHT' => '}' |
|
275 | + ) |
|
276 | + ); |
|
277 | + } |
|
278 | + catch(Exception $e) |
|
279 | + { |
|
280 | + $this->error=$e->getMessage(); |
|
281 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
282 | + return -1; |
|
283 | + } |
|
284 | + //print $odfHandler->__toString()."\n"; |
|
285 | 285 | |
286 | 286 | // Replace tags of lines for contacts |
287 | 287 | $contact_arrray=array(); |
@@ -297,52 +297,52 @@ discard block |
||
297 | 297 | { |
298 | 298 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
299 | 299 | |
300 | - $i=0; |
|
301 | - $contactstatic = new Contact($this->db); |
|
300 | + $i=0; |
|
301 | + $contactstatic = new Contact($this->db); |
|
302 | 302 | |
303 | - while($i < $num) |
|
304 | - { |
|
305 | - $obj = $this->db->fetch_object($result); |
|
303 | + while($i < $num) |
|
304 | + { |
|
305 | + $obj = $this->db->fetch_object($result); |
|
306 | 306 | |
307 | - $contact_arrray[$i] = $obj->rowid; |
|
308 | - $i++; |
|
309 | - } |
|
307 | + $contact_arrray[$i] = $obj->rowid; |
|
308 | + $i++; |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | if((is_array($contact_arrray) && count($contact_arrray) > 0)) |
312 | 312 | { |
313 | - try |
|
314 | - { |
|
315 | - $listlines = $odfHandler->setSegment('companycontacts'); |
|
316 | - |
|
317 | - foreach($contact_arrray as $array_key => $contact_id) |
|
318 | - { |
|
319 | - $res_contact = $contactstatic->fetch($contact_id); |
|
320 | - $tmparray=$this->get_substitutionarray_contact($contactstatic,$outputlangs,'contact'); |
|
321 | - foreach($tmparray as $key => $val) |
|
322 | - { |
|
323 | - try |
|
324 | - { |
|
325 | - $listlines->setVars($key, $val, true, 'UTF-8'); |
|
326 | - } |
|
327 | - catch(OdfException $e) |
|
328 | - { |
|
329 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
330 | - } |
|
331 | - catch(SegmentException $e) |
|
332 | - { |
|
333 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
334 | - } |
|
335 | - } |
|
336 | - $listlines->merge(); |
|
337 | - } |
|
338 | - $odfHandler->mergeSegment($listlines); |
|
339 | - } |
|
340 | - catch(OdfException $e) |
|
341 | - { |
|
342 | - $this->error=$e->getMessage(); |
|
343 | - dol_syslog($this->error, LOG_WARNING); |
|
344 | - //return -1; |
|
345 | - } |
|
313 | + try |
|
314 | + { |
|
315 | + $listlines = $odfHandler->setSegment('companycontacts'); |
|
316 | + |
|
317 | + foreach($contact_arrray as $array_key => $contact_id) |
|
318 | + { |
|
319 | + $res_contact = $contactstatic->fetch($contact_id); |
|
320 | + $tmparray=$this->get_substitutionarray_contact($contactstatic,$outputlangs,'contact'); |
|
321 | + foreach($tmparray as $key => $val) |
|
322 | + { |
|
323 | + try |
|
324 | + { |
|
325 | + $listlines->setVars($key, $val, true, 'UTF-8'); |
|
326 | + } |
|
327 | + catch(OdfException $e) |
|
328 | + { |
|
329 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
330 | + } |
|
331 | + catch(SegmentException $e) |
|
332 | + { |
|
333 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
334 | + } |
|
335 | + } |
|
336 | + $listlines->merge(); |
|
337 | + } |
|
338 | + $odfHandler->mergeSegment($listlines); |
|
339 | + } |
|
340 | + catch(OdfException $e) |
|
341 | + { |
|
342 | + $this->error=$e->getMessage(); |
|
343 | + dol_syslog($this->error, LOG_WARNING); |
|
344 | + //return -1; |
|
345 | + } |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | // Make substitutions into odt |
@@ -356,95 +356,95 @@ discard block |
||
356 | 356 | |
357 | 357 | // Call the ODTSubstitution hook |
358 | 358 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
359 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
359 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
360 | 360 | |
361 | 361 | // Replace variables into document |
362 | - foreach($tmparray as $key=>$value) |
|
363 | - { |
|
364 | - try { |
|
365 | - if (preg_match('/logo$/',$key)) // Image |
|
366 | - { |
|
367 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
368 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
369 | - } |
|
370 | - else // Text |
|
371 | - { |
|
372 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
373 | - } |
|
374 | - } |
|
375 | - catch (OdfException $e) |
|
376 | - { |
|
377 | - // setVars failed, probably because key not found |
|
362 | + foreach($tmparray as $key=>$value) |
|
363 | + { |
|
364 | + try { |
|
365 | + if (preg_match('/logo$/',$key)) // Image |
|
366 | + { |
|
367 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
368 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
369 | + } |
|
370 | + else // Text |
|
371 | + { |
|
372 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
373 | + } |
|
374 | + } |
|
375 | + catch (OdfException $e) |
|
376 | + { |
|
377 | + // setVars failed, probably because key not found |
|
378 | 378 | dol_syslog($e->getMessage(), LOG_INFO); |
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - // Replace labels translated |
|
383 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
384 | - foreach($tmparray as $key=>$value) |
|
385 | - { |
|
386 | - try { |
|
387 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
388 | - } |
|
389 | - catch (OdfException $e) |
|
390 | - { |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + // Replace labels translated |
|
383 | + $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
384 | + foreach($tmparray as $key=>$value) |
|
385 | + { |
|
386 | + try { |
|
387 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
388 | + } |
|
389 | + catch (OdfException $e) |
|
390 | + { |
|
391 | 391 | dol_syslog($e->getMessage(), LOG_INFO); |
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - // Call the beforeODTSave hook |
|
396 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
397 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
398 | - |
|
399 | - // Write new file |
|
400 | - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
401 | - try { |
|
402 | - $odfHandler->exportAsAttachedPDF($file); |
|
403 | - } catch (Exception $e) { |
|
404 | - $this->error=$e->getMessage(); |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + // Call the beforeODTSave hook |
|
396 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
397 | + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
398 | + |
|
399 | + // Write new file |
|
400 | + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
401 | + try { |
|
402 | + $odfHandler->exportAsAttachedPDF($file); |
|
403 | + } catch (Exception $e) { |
|
404 | + $this->error=$e->getMessage(); |
|
405 | 405 | dol_syslog($e->getMessage(), LOG_INFO); |
406 | - return -1; |
|
407 | - } |
|
408 | - } |
|
409 | - else { |
|
410 | - try { |
|
411 | - $odfHandler->creator = $user->getFullName($outputlangs); |
|
412 | - $odfHandler->title = $object->builddoc_filename; |
|
413 | - $odfHandler->subject = $object->builddoc_filename; |
|
414 | - |
|
415 | - if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) |
|
416 | - { |
|
417 | - $odfHandler->userdefined['dol_id'] = $object->id; |
|
418 | - $odfHandler->userdefined['dol_element'] = $object->element; |
|
419 | - } |
|
420 | - |
|
421 | - $odfHandler->saveToDisk($file); |
|
422 | - }catch (Exception $e){ |
|
423 | - $this->error=$e->getMessage(); |
|
406 | + return -1; |
|
407 | + } |
|
408 | + } |
|
409 | + else { |
|
410 | + try { |
|
411 | + $odfHandler->creator = $user->getFullName($outputlangs); |
|
412 | + $odfHandler->title = $object->builddoc_filename; |
|
413 | + $odfHandler->subject = $object->builddoc_filename; |
|
414 | + |
|
415 | + if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) |
|
416 | + { |
|
417 | + $odfHandler->userdefined['dol_id'] = $object->id; |
|
418 | + $odfHandler->userdefined['dol_element'] = $object->element; |
|
419 | + } |
|
420 | + |
|
421 | + $odfHandler->saveToDisk($file); |
|
422 | + }catch (Exception $e){ |
|
423 | + $this->error=$e->getMessage(); |
|
424 | 424 | dol_syslog($e->getMessage(), LOG_INFO); |
425 | - return -1; |
|
426 | - } |
|
427 | - } |
|
428 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
429 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
430 | - |
|
431 | - if (! empty($conf->global->MAIN_UMASK)) |
|
432 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
433 | - |
|
434 | - $odfHandler=null; // Destroy object |
|
435 | - |
|
436 | - $this->result = array('fullpath'=>$file); |
|
437 | - |
|
438 | - return 1; // Success |
|
439 | - } |
|
440 | - else |
|
441 | - { |
|
442 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
443 | - return -1; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - $this->error='UnknownError'; |
|
448 | - return -1; |
|
449 | - } |
|
425 | + return -1; |
|
426 | + } |
|
427 | + } |
|
428 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
429 | + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
430 | + |
|
431 | + if (! empty($conf->global->MAIN_UMASK)) |
|
432 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
433 | + |
|
434 | + $odfHandler=null; // Destroy object |
|
435 | + |
|
436 | + $this->result = array('fullpath'=>$file); |
|
437 | + |
|
438 | + return 1; // Success |
|
439 | + } |
|
440 | + else |
|
441 | + { |
|
442 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
443 | + return -1; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + $this->error='UnknownError'; |
|
448 | + return -1; |
|
449 | + } |
|
450 | 450 | } |
@@ -59,28 +59,28 @@ discard block |
||
59 | 59 | global $conf, $langs, $mysoc; |
60 | 60 | |
61 | 61 | // Load translation files required by the page |
62 | - $langs->loadLangs(array("main","companies")); |
|
62 | + $langs->loadLangs(array("main", "companies")); |
|
63 | 63 | |
64 | 64 | $this->db = $db; |
65 | 65 | $this->name = "ODT templates"; |
66 | 66 | $this->description = $langs->trans("DocumentModelOdt"); |
67 | - $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
67 | + $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
68 | 68 | |
69 | 69 | // Dimension page pour format A4 |
70 | 70 | $this->type = 'odt'; |
71 | 71 | $this->page_largeur = 0; |
72 | 72 | $this->page_hauteur = 0; |
73 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
74 | - $this->marge_gauche=0; |
|
75 | - $this->marge_droite=0; |
|
76 | - $this->marge_haute=0; |
|
77 | - $this->marge_basse=0; |
|
73 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
74 | + $this->marge_gauche = 0; |
|
75 | + $this->marge_droite = 0; |
|
76 | + $this->marge_haute = 0; |
|
77 | + $this->marge_basse = 0; |
|
78 | 78 | |
79 | - $this->option_logo = 1; // Affiche logo |
|
79 | + $this->option_logo = 1; // Affiche logo |
|
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | - $this->emetteur=$mysoc; |
|
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
82 | + $this->emetteur = $mysoc; |
|
83 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | function info($langs) |
94 | 94 | { |
95 | - global $conf,$langs; |
|
95 | + global $conf, $langs; |
|
96 | 96 | |
97 | 97 | // Load traductions files requiredby by page |
98 | 98 | $langs->loadLangs(array("companies", "errors")); |
@@ -100,76 +100,76 @@ discard block |
||
100 | 100 | $form = new Form($this->db); |
101 | 101 | |
102 | 102 | $texte = $this->description.".<br>\n"; |
103 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
104 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
105 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
106 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">'; |
|
107 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
103 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
104 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
105 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
106 | + $texte .= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">'; |
|
107 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
108 | 108 | |
109 | 109 | // List of directories area |
110 | - $texte.= '<tr><td>'; |
|
111 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
112 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); |
|
113 | - $listoffiles=array(); |
|
114 | - foreach($listofdir as $key=>$tmpdir) |
|
110 | + $texte .= '<tr><td>'; |
|
111 | + $texttitle = $langs->trans("ListOfDirectories"); |
|
112 | + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); |
|
113 | + $listoffiles = array(); |
|
114 | + foreach ($listofdir as $key=>$tmpdir) |
|
115 | 115 | { |
116 | - $tmpdir=trim($tmpdir); |
|
117 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
118 | - if (! $tmpdir) { unset($listofdir[$key]); continue; } |
|
119 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
116 | + $tmpdir = trim($tmpdir); |
|
117 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
118 | + if (!$tmpdir) { unset($listofdir[$key]); continue; } |
|
119 | + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); |
|
120 | 120 | else |
121 | 121 | { |
122 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment |
|
123 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
122 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment |
|
123 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
124 | 124 | } |
125 | 125 | } |
126 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
126 | + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); |
|
127 | 127 | // Add list of substitution keys |
128 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
129 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
130 | - |
|
131 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
132 | - $texte.= '<table><tr><td>'; |
|
133 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
134 | - $texte.=$conf->global->COMPANY_ADDON_PDF_ODT_PATH; |
|
135 | - $texte.= '</textarea>'; |
|
136 | - $texte.= '</td>'; |
|
137 | - $texte.= '<td align="center"> '; |
|
138 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
139 | - $texte.= '</td>'; |
|
140 | - $texte.= '</tr>'; |
|
141 | - $texte.= '</table>'; |
|
128 | + $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
129 | + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
130 | + |
|
131 | + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); |
|
132 | + $texte .= '<table><tr><td>'; |
|
133 | + $texte .= '<textarea class="flat" cols="60" name="value1">'; |
|
134 | + $texte .= $conf->global->COMPANY_ADDON_PDF_ODT_PATH; |
|
135 | + $texte .= '</textarea>'; |
|
136 | + $texte .= '</td>'; |
|
137 | + $texte .= '<td align="center"> '; |
|
138 | + $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
139 | + $texte .= '</td>'; |
|
140 | + $texte .= '</tr>'; |
|
141 | + $texte .= '</table>'; |
|
142 | 142 | |
143 | 143 | // Scan directories |
144 | - $nbofiles=count($listoffiles); |
|
145 | - if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) |
|
144 | + $nbofiles = count($listoffiles); |
|
145 | + if (!empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) |
|
146 | 146 | { |
147 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
147 | + $texte .= $langs->trans("NumberOfModelFilesFound").': <b>'; |
|
148 | 148 | //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
149 | - $texte.=$nbofiles; |
|
149 | + $texte .= $nbofiles; |
|
150 | 150 | //$texte.=$nbofiles?'</a>':''; |
151 | - $texte.='</b>'; |
|
151 | + $texte .= '</b>'; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | if ($nbofiles) |
155 | 155 | { |
156 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
157 | - foreach($listoffiles as $file) |
|
156 | + $texte .= '<div id="div_'.get_class($this).'" class="hidden">'; |
|
157 | + foreach ($listoffiles as $file) |
|
158 | 158 | { |
159 | - $texte.=$file['name'].'<br>'; |
|
159 | + $texte .= $file['name'].'<br>'; |
|
160 | 160 | } |
161 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
161 | + $texte .= '<div id="div_'.get_class($this).'">'; |
|
162 | 162 | } |
163 | 163 | |
164 | - $texte.= '</td>'; |
|
164 | + $texte .= '</td>'; |
|
165 | 165 | |
166 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
167 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
168 | - $texte.= '</td>'; |
|
169 | - $texte.= '</tr>'; |
|
166 | + $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
167 | + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
168 | + $texte .= '</td>'; |
|
169 | + $texte .= '</tr>'; |
|
170 | 170 | |
171 | - $texte.= '</table>'; |
|
172 | - $texte.= '</form>'; |
|
171 | + $texte .= '</table>'; |
|
172 | + $texte .= '</form>'; |
|
173 | 173 | |
174 | 174 | return $texte; |
175 | 175 | } |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | * @param int $hideref Do not show ref |
187 | 187 | * @return int 1 if OK, <=0 if KO |
188 | 188 | */ |
189 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
189 | + function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
190 | 190 | { |
191 | 191 | // phpcs:enable |
192 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
192 | + global $user, $langs, $conf, $mysoc, $hookmanager; |
|
193 | 193 | |
194 | 194 | if (empty($srctemplatepath)) |
195 | 195 | { |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | // Add odtgeneration hook |
201 | - if (! is_object($hookmanager)) |
|
201 | + if (!is_object($hookmanager)) |
|
202 | 202 | { |
203 | 203 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
204 | - $hookmanager=new HookManager($this->db); |
|
204 | + $hookmanager = new HookManager($this->db); |
|
205 | 205 | } |
206 | 206 | $hookmanager->initHooks(array('odtgeneration')); |
207 | 207 | global $action; |
208 | 208 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
210 | - $sav_charset_output=$outputlangs->charset_output; |
|
211 | - $outputlangs->charset_output='UTF-8'; |
|
209 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
210 | + $sav_charset_output = $outputlangs->charset_output; |
|
211 | + $outputlangs->charset_output = 'UTF-8'; |
|
212 | 212 | |
213 | 213 | // Load translation files required by the page |
214 | 214 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | { |
218 | 218 | $dir = $conf->societe->multidir_output[$object->entity]; |
219 | 219 | $objectref = dol_sanitizeFileName($object->id); |
220 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
220 | + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; |
|
221 | 221 | |
222 | - if (! file_exists($dir)) |
|
222 | + if (!file_exists($dir)) |
|
223 | 223 | { |
224 | 224 | if (dol_mkdir($dir) < 0) |
225 | 225 | { |
226 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
226 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
227 | 227 | return -1; |
228 | 228 | } |
229 | 229 | } |
@@ -231,28 +231,28 @@ discard block |
||
231 | 231 | if (file_exists($dir)) |
232 | 232 | { |
233 | 233 | //print "srctemplatepath=".$srctemplatepath; // Src filename |
234 | - $newfile=basename($srctemplatepath); |
|
235 | - $newfiletmp=preg_replace('/\.od(s|t)/i','',$newfile); |
|
236 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
237 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
234 | + $newfile = basename($srctemplatepath); |
|
235 | + $newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile); |
|
236 | + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); |
|
237 | + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); |
|
238 | 238 | // Get extension (ods or odt) |
239 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
240 | - if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) |
|
239 | + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); |
|
240 | + if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) |
|
241 | 241 | { |
242 | 242 | $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; |
243 | 243 | } |
244 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
244 | + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
245 | 245 | { |
246 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
247 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
248 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
246 | + $format = $conf->global->MAIN_DOC_USE_TIMING; |
|
247 | + if ($format == '1') $format = '%Y%m%d%H%M%S'; |
|
248 | + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; |
|
249 | 249 | } |
250 | 250 | else |
251 | 251 | { |
252 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
252 | + $filename = $newfiletmp.'.'.$newfileformat; |
|
253 | 253 | } |
254 | - $file=$dir.'/'.$filename; |
|
255 | - $object->builddoc_filename=$filename; // For triggers |
|
254 | + $file = $dir.'/'.$filename; |
|
255 | + $object->builddoc_filename = $filename; // For triggers |
|
256 | 256 | //print "newfileformat=".$newfileformat; |
257 | 257 | //print "newdir=".$dir; |
258 | 258 | //print "newfile=".$newfile; |
@@ -269,22 +269,22 @@ discard block |
||
269 | 269 | $srctemplatepath, |
270 | 270 | array( |
271 | 271 | 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], |
272 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
272 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
273 | 273 | 'DELIMITER_LEFT' => '{', |
274 | 274 | 'DELIMITER_RIGHT' => '}' |
275 | 275 | ) |
276 | 276 | ); |
277 | 277 | } |
278 | - catch(Exception $e) |
|
278 | + catch (Exception $e) |
|
279 | 279 | { |
280 | - $this->error=$e->getMessage(); |
|
280 | + $this->error = $e->getMessage(); |
|
281 | 281 | dol_syslog($e->getMessage(), LOG_INFO); |
282 | 282 | return -1; |
283 | 283 | } |
284 | 284 | //print $odfHandler->__toString()."\n"; |
285 | 285 | |
286 | 286 | // Replace tags of lines for contacts |
287 | - $contact_arrray=array(); |
|
287 | + $contact_arrray = array(); |
|
288 | 288 | |
289 | 289 | $sql = "SELECT p.rowid"; |
290 | 290 | $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | { |
298 | 298 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
299 | 299 | |
300 | - $i=0; |
|
300 | + $i = 0; |
|
301 | 301 | $contactstatic = new Contact($this->db); |
302 | 302 | |
303 | - while($i < $num) |
|
303 | + while ($i < $num) |
|
304 | 304 | { |
305 | 305 | $obj = $this->db->fetch_object($result); |
306 | 306 | |
@@ -308,27 +308,27 @@ discard block |
||
308 | 308 | $i++; |
309 | 309 | } |
310 | 310 | } |
311 | - if((is_array($contact_arrray) && count($contact_arrray) > 0)) |
|
311 | + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) |
|
312 | 312 | { |
313 | 313 | try |
314 | 314 | { |
315 | 315 | $listlines = $odfHandler->setSegment('companycontacts'); |
316 | 316 | |
317 | - foreach($contact_arrray as $array_key => $contact_id) |
|
317 | + foreach ($contact_arrray as $array_key => $contact_id) |
|
318 | 318 | { |
319 | 319 | $res_contact = $contactstatic->fetch($contact_id); |
320 | - $tmparray=$this->get_substitutionarray_contact($contactstatic,$outputlangs,'contact'); |
|
321 | - foreach($tmparray as $key => $val) |
|
320 | + $tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); |
|
321 | + foreach ($tmparray as $key => $val) |
|
322 | 322 | { |
323 | 323 | try |
324 | 324 | { |
325 | 325 | $listlines->setVars($key, $val, true, 'UTF-8'); |
326 | 326 | } |
327 | - catch(OdfException $e) |
|
327 | + catch (OdfException $e) |
|
328 | 328 | { |
329 | 329 | dol_syslog($e->getMessage(), LOG_INFO); |
330 | 330 | } |
331 | - catch(SegmentException $e) |
|
331 | + catch (SegmentException $e) |
|
332 | 332 | { |
333 | 333 | dol_syslog($e->getMessage(), LOG_INFO); |
334 | 334 | } |
@@ -337,32 +337,32 @@ discard block |
||
337 | 337 | } |
338 | 338 | $odfHandler->mergeSegment($listlines); |
339 | 339 | } |
340 | - catch(OdfException $e) |
|
340 | + catch (OdfException $e) |
|
341 | 341 | { |
342 | - $this->error=$e->getMessage(); |
|
342 | + $this->error = $e->getMessage(); |
|
343 | 343 | dol_syslog($this->error, LOG_WARNING); |
344 | 344 | //return -1; |
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Make substitutions into odt |
349 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
350 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
351 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($object,$outputlangs); |
|
352 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
349 | + $array_user = $this->get_substitutionarray_user($user, $outputlangs); |
|
350 | + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); |
|
351 | + $array_thirdparty = $this->get_substitutionarray_thirdparty($object, $outputlangs); |
|
352 | + $array_other = $this->get_substitutionarray_other($outputlangs); |
|
353 | 353 | |
354 | - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other); |
|
354 | + $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other); |
|
355 | 355 | complete_substitutions_array($tmparray, $outputlangs, $object); |
356 | 356 | |
357 | 357 | // Call the ODTSubstitution hook |
358 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
359 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
358 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
359 | + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
360 | 360 | |
361 | 361 | // Replace variables into document |
362 | - foreach($tmparray as $key=>$value) |
|
362 | + foreach ($tmparray as $key=>$value) |
|
363 | 363 | { |
364 | 364 | try { |
365 | - if (preg_match('/logo$/',$key)) // Image |
|
365 | + if (preg_match('/logo$/', $key)) // Image |
|
366 | 366 | { |
367 | 367 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
368 | 368 | else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | // Replace labels translated |
383 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
384 | - foreach($tmparray as $key=>$value) |
|
383 | + $tmparray = $outputlangs->get_translations_for_substitutions(); |
|
384 | + foreach ($tmparray as $key=>$value) |
|
385 | 385 | { |
386 | 386 | try { |
387 | 387 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | // Call the beforeODTSave hook |
396 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
397 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
396 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
397 | + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
398 | 398 | |
399 | 399 | // Write new file |
400 | 400 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
401 | 401 | try { |
402 | 402 | $odfHandler->exportAsAttachedPDF($file); |
403 | 403 | } catch (Exception $e) { |
404 | - $this->error=$e->getMessage(); |
|
404 | + $this->error = $e->getMessage(); |
|
405 | 405 | dol_syslog($e->getMessage(), LOG_INFO); |
406 | 406 | return -1; |
407 | 407 | } |
@@ -412,39 +412,39 @@ discard block |
||
412 | 412 | $odfHandler->title = $object->builddoc_filename; |
413 | 413 | $odfHandler->subject = $object->builddoc_filename; |
414 | 414 | |
415 | - if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) |
|
415 | + if (!empty($conf->global->ODT_ADD_DOLIBARR_ID)) |
|
416 | 416 | { |
417 | 417 | $odfHandler->userdefined['dol_id'] = $object->id; |
418 | 418 | $odfHandler->userdefined['dol_element'] = $object->element; |
419 | 419 | } |
420 | 420 | |
421 | 421 | $odfHandler->saveToDisk($file); |
422 | - }catch (Exception $e){ |
|
423 | - $this->error=$e->getMessage(); |
|
422 | + } catch (Exception $e) { |
|
423 | + $this->error = $e->getMessage(); |
|
424 | 424 | dol_syslog($e->getMessage(), LOG_INFO); |
425 | 425 | return -1; |
426 | 426 | } |
427 | 427 | } |
428 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
429 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
428 | + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); |
|
429 | + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
430 | 430 | |
431 | - if (! empty($conf->global->MAIN_UMASK)) |
|
431 | + if (!empty($conf->global->MAIN_UMASK)) |
|
432 | 432 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
433 | 433 | |
434 | - $odfHandler=null; // Destroy object |
|
434 | + $odfHandler = null; // Destroy object |
|
435 | 435 | |
436 | 436 | $this->result = array('fullpath'=>$file); |
437 | 437 | |
438 | - return 1; // Success |
|
438 | + return 1; // Success |
|
439 | 439 | } |
440 | 440 | else |
441 | 441 | { |
442 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
442 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
443 | 443 | return -1; |
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - $this->error='UnknownError'; |
|
447 | + $this->error = 'UnknownError'; |
|
448 | 448 | return -1; |
449 | 449 | } |
450 | 450 | } |
@@ -80,7 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | // Recupere emmetteur |
82 | 82 | $this->emetteur=$mysoc; |
83 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini |
|
83 | + if (! $this->emetteur->country_code) { |
|
84 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
85 | + } |
|
86 | + // Par defaut, si n'etait pas defini |
|
84 | 87 | } |
85 | 88 | |
86 | 89 | |
@@ -116,11 +119,14 @@ discard block |
||
116 | 119 | $tmpdir=trim($tmpdir); |
117 | 120 | $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
118 | 121 | if (! $tmpdir) { unset($listofdir[$key]); continue; } |
119 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
120 | - else |
|
122 | + if (! is_dir($tmpdir)) { |
|
123 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
124 | + } else |
|
121 | 125 | { |
122 | 126 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment |
123 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
127 | + if (count($tmpfiles)) { |
|
128 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
129 | + } |
|
124 | 130 | } |
125 | 131 | } |
126 | 132 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -206,7 +212,9 @@ discard block |
||
206 | 212 | $hookmanager->initHooks(array('odtgeneration')); |
207 | 213 | global $action; |
208 | 214 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
215 | + if (! is_object($outputlangs)) { |
|
216 | + $outputlangs=$langs; |
|
217 | + } |
|
210 | 218 | $sav_charset_output=$outputlangs->charset_output; |
211 | 219 | $outputlangs->charset_output='UTF-8'; |
212 | 220 | |
@@ -217,7 +225,9 @@ discard block |
||
217 | 225 | { |
218 | 226 | $dir = $conf->societe->multidir_output[$object->entity]; |
219 | 227 | $objectref = dol_sanitizeFileName($object->id); |
220 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
228 | + if (! preg_match('/specimen/i',$objectref)) { |
|
229 | + $dir.= "/" . $objectref; |
|
230 | + } |
|
221 | 231 | |
222 | 232 | if (! file_exists($dir)) |
223 | 233 | { |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
245 | 255 | { |
246 | 256 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
247 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
257 | + if ($format == '1') { |
|
258 | + $format='%Y%m%d%H%M%S'; |
|
259 | + } |
|
248 | 260 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
249 | - } |
|
250 | - else |
|
261 | + } else |
|
251 | 262 | { |
252 | 263 | $filename=$newfiletmp.'.'.$newfileformat; |
253 | 264 | } |
@@ -274,8 +285,7 @@ discard block |
||
274 | 285 | 'DELIMITER_RIGHT' => '}' |
275 | 286 | ) |
276 | 287 | ); |
277 | - } |
|
278 | - catch(Exception $e) |
|
288 | + } catch(Exception $e) |
|
279 | 289 | { |
280 | 290 | $this->error=$e->getMessage(); |
281 | 291 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -323,12 +333,10 @@ discard block |
||
323 | 333 | try |
324 | 334 | { |
325 | 335 | $listlines->setVars($key, $val, true, 'UTF-8'); |
326 | - } |
|
327 | - catch(OdfException $e) |
|
336 | + } catch(OdfException $e) |
|
328 | 337 | { |
329 | 338 | dol_syslog($e->getMessage(), LOG_INFO); |
330 | - } |
|
331 | - catch(SegmentException $e) |
|
339 | + } catch(SegmentException $e) |
|
332 | 340 | { |
333 | 341 | dol_syslog($e->getMessage(), LOG_INFO); |
334 | 342 | } |
@@ -336,8 +344,7 @@ discard block |
||
336 | 344 | $listlines->merge(); |
337 | 345 | } |
338 | 346 | $odfHandler->mergeSegment($listlines); |
339 | - } |
|
340 | - catch(OdfException $e) |
|
347 | + } catch(OdfException $e) |
|
341 | 348 | { |
342 | 349 | $this->error=$e->getMessage(); |
343 | 350 | dol_syslog($this->error, LOG_WARNING); |
@@ -362,17 +369,18 @@ discard block |
||
362 | 369 | foreach($tmparray as $key=>$value) |
363 | 370 | { |
364 | 371 | try { |
365 | - if (preg_match('/logo$/',$key)) // Image |
|
372 | + if (preg_match('/logo$/',$key)) { |
|
373 | + // Image |
|
366 | 374 | { |
367 | 375 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
368 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
369 | - } |
|
370 | - else // Text |
|
376 | + } else { |
|
377 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
378 | + } |
|
379 | + } else // Text |
|
371 | 380 | { |
372 | 381 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
373 | 382 | } |
374 | - } |
|
375 | - catch (OdfException $e) |
|
383 | + } catch (OdfException $e) |
|
376 | 384 | { |
377 | 385 | // setVars failed, probably because key not found |
378 | 386 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -385,8 +393,7 @@ discard block |
||
385 | 393 | { |
386 | 394 | try { |
387 | 395 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
388 | - } |
|
389 | - catch (OdfException $e) |
|
396 | + } catch (OdfException $e) |
|
390 | 397 | { |
391 | 398 | dol_syslog($e->getMessage(), LOG_INFO); |
392 | 399 | } |
@@ -405,8 +412,7 @@ discard block |
||
405 | 412 | dol_syslog($e->getMessage(), LOG_INFO); |
406 | 413 | return -1; |
407 | 414 | } |
408 | - } |
|
409 | - else { |
|
415 | + } else { |
|
410 | 416 | try { |
411 | 417 | $odfHandler->creator = $user->getFullName($outputlangs); |
412 | 418 | $odfHandler->title = $object->builddoc_filename; |
@@ -419,7 +425,7 @@ discard block |
||
419 | 425 | } |
420 | 426 | |
421 | 427 | $odfHandler->saveToDisk($file); |
422 | - }catch (Exception $e){ |
|
428 | + } catch (Exception $e){ |
|
423 | 429 | $this->error=$e->getMessage(); |
424 | 430 | dol_syslog($e->getMessage(), LOG_INFO); |
425 | 431 | return -1; |
@@ -428,16 +434,16 @@ discard block |
||
428 | 434 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
429 | 435 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
430 | 436 | |
431 | - if (! empty($conf->global->MAIN_UMASK)) |
|
432 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
437 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
438 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
439 | + } |
|
433 | 440 | |
434 | 441 | $odfHandler=null; // Destroy object |
435 | 442 | |
436 | 443 | $this->result = array('fullpath'=>$file); |
437 | 444 | |
438 | 445 | return 1; // Success |
439 | - } |
|
440 | - else |
|
446 | + } else |
|
441 | 447 | { |
442 | 448 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
443 | 449 | return -1; |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | abstract class ModeleThirdPartyDoc extends CommonDocGenerator |
35 | 35 | { |
36 | 36 | /** |
37 | - * @var string Error code (or message) |
|
38 | - */ |
|
39 | - public $error=''; |
|
37 | + * @var string Error code (or message) |
|
38 | + */ |
|
39 | + public $error=''; |
|
40 | 40 | |
41 | 41 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
42 | 42 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | { |
70 | 70 | /** |
71 | 71 | * @var string Error code (or message) |
72 | - */ |
|
73 | - public $error=''; |
|
72 | + */ |
|
73 | + public $error=''; |
|
74 | 74 | |
75 | 75 | /** Renvoi la description par defaut du modele de numerotation |
76 | 76 | * |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
249 | - /** |
|
250 | - * Check if mask/numbering use prefix |
|
251 | - * |
|
252 | - * @return int 0=no, 1=yes |
|
249 | + /** |
|
250 | + * Check if mask/numbering use prefix |
|
251 | + * |
|
252 | + * @return int 0=no, 1=yes |
|
253 | 253 | */ |
254 | 254 | function verif_prefixIsUsed() |
255 | 255 | { |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | abstract class ModeleAccountancyCode |
267 | 267 | { |
268 | 268 | /** |
269 | - * @var string Error code (or message) |
|
270 | - */ |
|
271 | - public $error=''; |
|
269 | + * @var string Error code (or message) |
|
270 | + */ |
|
271 | + public $error=''; |
|
272 | 272 | |
273 | 273 | |
274 | 274 | /** Return description of module |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
398 | 398 | { |
399 | 399 | // phpcs:enable |
400 | - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); |
|
400 | + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); |
|
401 | 401 | |
402 | - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
402 | + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
403 | 403 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var string Error code (or message) |
38 | 38 | */ |
39 | - public $error=''; |
|
39 | + public $error = ''; |
|
40 | 40 | |
41 | 41 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
42 | 42 | /** |
@@ -46,16 +46,16 @@ discard block |
||
46 | 46 | * @param integer $maxfilenamelength Max length of value to show |
47 | 47 | * @return array List of templates |
48 | 48 | */ |
49 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
49 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
50 | 50 | { |
51 | 51 | // phpcs:enable |
52 | 52 | global $conf; |
53 | 53 | |
54 | - $type='company'; |
|
55 | - $liste=array(); |
|
54 | + $type = 'company'; |
|
55 | + $liste = array(); |
|
56 | 56 | |
57 | 57 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
58 | - $liste = getListOfModels($db,$type,$maxfilenamelength); |
|
58 | + $liste = getListOfModels($db, $type, $maxfilenamelength); |
|
59 | 59 | |
60 | 60 | return $liste; |
61 | 61 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @var string Error code (or message) |
72 | 72 | */ |
73 | - public $error=''; |
|
73 | + public $error = ''; |
|
74 | 74 | |
75 | 75 | /** Renvoi la description par defaut du modele de numerotation |
76 | 76 | * |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param int $type Type |
123 | 123 | * @return string Value |
124 | 124 | */ |
125 | - function getNextValue($objsoc=0,$type=-1) |
|
125 | + function getNextValue($objsoc = 0, $type = -1) |
|
126 | 126 | { |
127 | 127 | global $langs; |
128 | 128 | return $langs->trans("Function_getNextValue_InModuleNotWorking"); |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @param integer $maxfilenamelength Max length of value to show |
154 | 154 | * @return array List of numbers |
155 | 155 | */ |
156 | - static function liste_modeles($db,$maxfilenamelength=0) |
|
156 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
157 | 157 | { |
158 | 158 | // phpcs:enable |
159 | - $liste=array(); |
|
160 | - $sql =""; |
|
159 | + $liste = array(); |
|
160 | + $sql = ""; |
|
161 | 161 | |
162 | 162 | $resql = $db->query($sql); |
163 | 163 | if ($resql) |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | while ($i < $num) |
168 | 168 | { |
169 | 169 | $row = $db->fetch_row($resql); |
170 | - $liste[$row[0]]=$row[1]; |
|
170 | + $liste[$row[0]] = $row[1]; |
|
171 | 171 | $i++; |
172 | 172 | } |
173 | 173 | } |
@@ -186,61 +186,61 @@ discard block |
||
186 | 186 | * @param int $type -1=Nothing, 0=Customer, 1=Supplier |
187 | 187 | * @return string HTML translated description |
188 | 188 | */ |
189 | - function getToolTip($langs,$soc,$type) |
|
189 | + function getToolTip($langs, $soc, $type) |
|
190 | 190 | { |
191 | 191 | global $conf; |
192 | 192 | |
193 | 193 | $langs->load("admin"); |
194 | 194 | |
195 | - $s=''; |
|
196 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
197 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
198 | - if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
199 | - if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
200 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
201 | - $s.='<br>'; |
|
202 | - $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
195 | + $s = ''; |
|
196 | + if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
197 | + if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
198 | + if ($type == 0) $s .= $langs->trans("CustomerCodeDesc").'<br>'; |
|
199 | + if ($type == 1) $s .= $langs->trans("SupplierCodeDesc").'<br>'; |
|
200 | + if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
201 | + $s .= '<br>'; |
|
202 | + $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
203 | 203 | if ($type == 0) |
204 | 204 | { |
205 | - $s.=$langs->trans("RequiredIfCustomer").': '; |
|
206 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
207 | - $s.=yn(!$this->code_null,1,2); |
|
208 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
209 | - $s.='<br>'; |
|
205 | + $s .= $langs->trans("RequiredIfCustomer").': '; |
|
206 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
207 | + $s .= yn(!$this->code_null, 1, 2); |
|
208 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
209 | + $s .= '<br>'; |
|
210 | 210 | } |
211 | 211 | if ($type == 1) |
212 | 212 | { |
213 | - $s.=$langs->trans("RequiredIfSupplier").': '; |
|
214 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
215 | - $s.=yn(!$this->code_null,1,2); |
|
216 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
217 | - $s.='<br>'; |
|
213 | + $s .= $langs->trans("RequiredIfSupplier").': '; |
|
214 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
215 | + $s .= yn(!$this->code_null, 1, 2); |
|
216 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
217 | + $s .= '<br>'; |
|
218 | 218 | } |
219 | 219 | if ($type == -1) |
220 | 220 | { |
221 | - $s.=$langs->trans("Required").': '; |
|
222 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
223 | - $s.=yn(!$this->code_null,1,2); |
|
224 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
225 | - $s.='<br>'; |
|
221 | + $s .= $langs->trans("Required").': '; |
|
222 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>'; |
|
223 | + $s .= yn(!$this->code_null, 1, 2); |
|
224 | + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; |
|
225 | + $s .= '<br>'; |
|
226 | 226 | } |
227 | - $s.=$langs->trans("CanBeModifiedIfOk").': '; |
|
228 | - $s.=yn($this->code_modifiable,1,2); |
|
229 | - $s.='<br>'; |
|
230 | - $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>'; |
|
231 | - $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>'; |
|
232 | - $s.='<br>'; |
|
227 | + $s .= $langs->trans("CanBeModifiedIfOk").': '; |
|
228 | + $s .= yn($this->code_modifiable, 1, 2); |
|
229 | + $s .= '<br>'; |
|
230 | + $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>'; |
|
231 | + $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>'; |
|
232 | + $s .= '<br>'; |
|
233 | 233 | if ($type == 0 || $type == -1) |
234 | 234 | { |
235 | - $nextval=$this->getNextValue($soc,0); |
|
236 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
237 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
|
235 | + $nextval = $this->getNextValue($soc, 0); |
|
236 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
237 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>'; |
|
238 | 238 | } |
239 | 239 | if ($type == 1 || $type == -1) |
240 | 240 | { |
241 | - $nextval=$this->getNextValue($soc,1); |
|
242 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
243 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
|
241 | + $nextval = $this->getNextValue($soc, 1); |
|
242 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
243 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>'; |
|
244 | 244 | } |
245 | 245 | return $s; |
246 | 246 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | /** |
269 | 269 | * @var string Error code (or message) |
270 | 270 | */ |
271 | - public $error=''; |
|
271 | + public $error = ''; |
|
272 | 272 | |
273 | 273 | |
274 | 274 | /** Return description of module |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
290 | 290 | * @return string Example |
291 | 291 | */ |
292 | - function getExample($langs,$objsoc=0,$type=-1) |
|
292 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
293 | 293 | { |
294 | 294 | $langs->load("bills"); |
295 | 295 | return $langs->trans("NoExample"); |
@@ -329,31 +329,31 @@ discard block |
||
329 | 329 | * @param int $type -1=Nothing, 0=Customer, 1=Supplier |
330 | 330 | * @return string HTML translated description |
331 | 331 | */ |
332 | - function getToolTip($langs,$soc,$type) |
|
332 | + function getToolTip($langs, $soc, $type) |
|
333 | 333 | { |
334 | - global $conf,$db; |
|
334 | + global $conf, $db; |
|
335 | 335 | |
336 | 336 | $langs->load("admin"); |
337 | 337 | |
338 | - $s=''; |
|
339 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
340 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
338 | + $s = ''; |
|
339 | + if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
340 | + if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
341 | 341 | //$s.='<br>'; |
342 | 342 | //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
343 | - $s.='<br>'; |
|
343 | + $s .= '<br>'; |
|
344 | 344 | if ($type == 0 || $type == -1) |
345 | 345 | { |
346 | - $result=$this->get_code($db,$soc,'customer'); |
|
347 | - $nextval=$this->code; |
|
348 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
349 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
|
346 | + $result = $this->get_code($db, $soc, 'customer'); |
|
347 | + $nextval = $this->code; |
|
348 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
349 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>'; |
|
350 | 350 | } |
351 | 351 | if ($type == 1 || $type == -1) |
352 | 352 | { |
353 | - $result=$this->get_code($db,$soc,'supplier'); |
|
354 | - $nextval=$this->code; |
|
355 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
356 | - $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
|
353 | + $result = $this->get_code($db, $soc, 'supplier'); |
|
354 | + $nextval = $this->code; |
|
355 | + if (empty($nextval)) $nextval = $langs->trans("Undefined"); |
|
356 | + $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>'; |
|
357 | 357 | } |
358 | 358 | return $s; |
359 | 359 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param int $type 'customer' or 'supplier' |
368 | 368 | * @return int >=0 if OK, <0 if KO |
369 | 369 | */ |
370 | - function get_code($db, $societe, $type='') |
|
370 | + function get_code($db, $societe, $type = '') |
|
371 | 371 | { |
372 | 372 | // phpcs:enable |
373 | 373 | global $langs; |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | * @deprecated Use the new function generateDocument of Facture class |
395 | 395 | * @see Societe::generateDocument() |
396 | 396 | */ |
397 | -function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
|
397 | +function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
398 | 398 | { |
399 | 399 | // phpcs:enable |
400 | - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); |
|
400 | + dol_syslog(__METHOD__." is deprecated", LOG_WARNING); |
|
401 | 401 | |
402 | 402 | return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); |
403 | 403 | } |
@@ -138,10 +138,18 @@ discard block |
||
138 | 138 | global $langs; |
139 | 139 | $langs->load("admin"); |
140 | 140 | |
141 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
142 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
143 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
144 | - if ($this->version) return $this->version; |
|
141 | + if ($this->version == 'development') { |
|
142 | + return $langs->trans("VersionDevelopment"); |
|
143 | + } |
|
144 | + if ($this->version == 'experimental') { |
|
145 | + return $langs->trans("VersionExperimental"); |
|
146 | + } |
|
147 | + if ($this->version == 'dolibarr') { |
|
148 | + return DOL_VERSION; |
|
149 | + } |
|
150 | + if ($this->version) { |
|
151 | + return $this->version; |
|
152 | + } |
|
145 | 153 | return $langs->trans("NotAvailable"); |
146 | 154 | } |
147 | 155 | |
@@ -170,8 +178,7 @@ discard block |
||
170 | 178 | $liste[$row[0]]=$row[1]; |
171 | 179 | $i++; |
172 | 180 | } |
173 | - } |
|
174 | - else |
|
181 | + } else |
|
175 | 182 | { |
176 | 183 | return -1; |
177 | 184 | } |
@@ -193,35 +200,57 @@ discard block |
||
193 | 200 | $langs->load("admin"); |
194 | 201 | |
195 | 202 | $s=''; |
196 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
197 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
198 | - if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
199 | - if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
200 | - if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
203 | + if ($type == -1) { |
|
204 | + $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>'; |
|
205 | + } |
|
206 | + if ($type == -1) { |
|
207 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
208 | + } |
|
209 | + if ($type == 0) { |
|
210 | + $s.=$langs->trans("CustomerCodeDesc").'<br>'; |
|
211 | + } |
|
212 | + if ($type == 1) { |
|
213 | + $s.=$langs->trans("SupplierCodeDesc").'<br>'; |
|
214 | + } |
|
215 | + if ($type != -1) { |
|
216 | + $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>'; |
|
217 | + } |
|
201 | 218 | $s.='<br>'; |
202 | 219 | $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
203 | 220 | if ($type == 0) |
204 | 221 | { |
205 | 222 | $s.=$langs->trans("RequiredIfCustomer").': '; |
206 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
223 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
224 | + $s.='<strike>'; |
|
225 | + } |
|
207 | 226 | $s.=yn(!$this->code_null,1,2); |
208 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
227 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
228 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
229 | + } |
|
209 | 230 | $s.='<br>'; |
210 | 231 | } |
211 | 232 | if ($type == 1) |
212 | 233 | { |
213 | 234 | $s.=$langs->trans("RequiredIfSupplier").': '; |
214 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
235 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
236 | + $s.='<strike>'; |
|
237 | + } |
|
215 | 238 | $s.=yn(!$this->code_null,1,2); |
216 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
239 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
240 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
241 | + } |
|
217 | 242 | $s.='<br>'; |
218 | 243 | } |
219 | 244 | if ($type == -1) |
220 | 245 | { |
221 | 246 | $s.=$langs->trans("Required").': '; |
222 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>'; |
|
247 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
248 | + $s.='<strike>'; |
|
249 | + } |
|
223 | 250 | $s.=yn(!$this->code_null,1,2); |
224 | - if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
251 | + if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) { |
|
252 | + $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')'; |
|
253 | + } |
|
225 | 254 | $s.='<br>'; |
226 | 255 | } |
227 | 256 | $s.=$langs->trans("CanBeModifiedIfOk").': '; |
@@ -233,13 +262,17 @@ discard block |
||
233 | 262 | if ($type == 0 || $type == -1) |
234 | 263 | { |
235 | 264 | $nextval=$this->getNextValue($soc,0); |
236 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
265 | + if (empty($nextval)) { |
|
266 | + $nextval=$langs->trans("Undefined"); |
|
267 | + } |
|
237 | 268 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
238 | 269 | } |
239 | 270 | if ($type == 1 || $type == -1) |
240 | 271 | { |
241 | 272 | $nextval=$this->getNextValue($soc,1); |
242 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
273 | + if (empty($nextval)) { |
|
274 | + $nextval=$langs->trans("Undefined"); |
|
275 | + } |
|
243 | 276 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
244 | 277 | } |
245 | 278 | return $s; |
@@ -314,10 +347,18 @@ discard block |
||
314 | 347 | global $langs; |
315 | 348 | $langs->load("admin"); |
316 | 349 | |
317 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
318 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
319 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
320 | - if ($this->version) return $this->version; |
|
350 | + if ($this->version == 'development') { |
|
351 | + return $langs->trans("VersionDevelopment"); |
|
352 | + } |
|
353 | + if ($this->version == 'experimental') { |
|
354 | + return $langs->trans("VersionExperimental"); |
|
355 | + } |
|
356 | + if ($this->version == 'dolibarr') { |
|
357 | + return DOL_VERSION; |
|
358 | + } |
|
359 | + if ($this->version) { |
|
360 | + return $this->version; |
|
361 | + } |
|
321 | 362 | return $langs->trans("NotAvailable"); |
322 | 363 | } |
323 | 364 | |
@@ -336,8 +377,12 @@ discard block |
||
336 | 377 | $langs->load("admin"); |
337 | 378 | |
338 | 379 | $s=''; |
339 | - if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
340 | - if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
380 | + if ($type == -1) { |
|
381 | + $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>'; |
|
382 | + } |
|
383 | + if ($type == -1) { |
|
384 | + $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>'; |
|
385 | + } |
|
341 | 386 | //$s.='<br>'; |
342 | 387 | //$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
343 | 388 | $s.='<br>'; |
@@ -345,14 +390,18 @@ discard block |
||
345 | 390 | { |
346 | 391 | $result=$this->get_code($db,$soc,'customer'); |
347 | 392 | $nextval=$this->code; |
348 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
393 | + if (empty($nextval)) { |
|
394 | + $nextval=$langs->trans("Undefined"); |
|
395 | + } |
|
349 | 396 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>'; |
350 | 397 | } |
351 | 398 | if ($type == 1 || $type == -1) |
352 | 399 | { |
353 | 400 | $result=$this->get_code($db,$soc,'supplier'); |
354 | 401 | $nextval=$this->code; |
355 | - if (empty($nextval)) $nextval=$langs->trans("Undefined"); |
|
402 | + if (empty($nextval)) { |
|
403 | + $nextval=$langs->trans("Undefined"); |
|
404 | + } |
|
356 | 405 | $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>'; |
357 | 406 | } |
358 | 407 | return $s; |
@@ -34,319 +34,319 @@ |
||
34 | 34 | */ |
35 | 35 | class mod_codeclient_elephant extends ModeleThirdPartyCode |
36 | 36 | { |
37 | - /** |
|
38 | - * @var string Nom du modele |
|
39 | - * @deprecated |
|
40 | - * @see name |
|
41 | - */ |
|
42 | - public $nom='Elephant'; |
|
37 | + /** |
|
38 | + * @var string Nom du modele |
|
39 | + * @deprecated |
|
40 | + * @see name |
|
41 | + */ |
|
42 | + public $nom='Elephant'; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string model name |
|
46 | - */ |
|
47 | - public $name='Elephant'; |
|
44 | + /** |
|
45 | + * @var string model name |
|
46 | + */ |
|
47 | + public $name='Elephant'; |
|
48 | 48 | |
49 | - public $code_modifiable; // Code modifiable |
|
49 | + public $code_modifiable; // Code modifiable |
|
50 | 50 | |
51 | - public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
51 | + public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
52 | 52 | |
53 | - public $code_modifiable_null; // Code modifiables si il est null |
|
53 | + public $code_modifiable_null; // Code modifiables si il est null |
|
54 | 54 | |
55 | - public $code_null; // Code facultatif |
|
55 | + public $code_null; // Code facultatif |
|
56 | 56 | |
57 | - /** |
|
57 | + /** |
|
58 | 58 | * Dolibarr version of the loaded document |
59 | 59 | * @public string |
60 | 60 | */ |
61 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
62 | - |
|
63 | - public $code_auto; // Numerotation automatique |
|
64 | - |
|
65 | - public $searchcode; // String de recherche |
|
66 | - |
|
67 | - public $numbitcounter; // Nombre de chiffres du compteur |
|
68 | - |
|
69 | - public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * Constructor |
|
74 | - */ |
|
75 | - function __construct() |
|
76 | - { |
|
77 | - $this->code_null = 0; |
|
78 | - $this->code_modifiable = 1; |
|
79 | - $this->code_modifiable_invalide = 1; |
|
80 | - $this->code_modifiable_null = 1; |
|
81 | - $this->code_auto = 1; |
|
82 | - $this->prefixIsRequired = 0; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** Return description of module |
|
87 | - * |
|
88 | - * @param Translate $langs Object langs |
|
89 | - * @return string Description of module |
|
90 | - */ |
|
91 | - function info($langs) |
|
92 | - { |
|
93 | - global $conf, $mc; |
|
94 | - global $form; |
|
95 | - |
|
96 | - $langs->load("companies"); |
|
97 | - |
|
98 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
99 | - |
|
100 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
101 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
102 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
103 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
104 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
105 | - $texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
106 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
107 | - |
|
108 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty")); |
|
109 | - //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering |
|
110 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
111 | - $tooltip.=$langs->trans("GenericMaskCodes4b"); |
|
112 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
113 | - |
|
114 | - // Parametrage du prefix customers |
|
115 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
116 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
117 | - |
|
118 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
119 | - |
|
120 | - $texte.= '</tr>'; |
|
121 | - |
|
122 | - // Parametrage du prefix suppliers |
|
123 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
124 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
125 | - $texte.= '</tr>'; |
|
126 | - |
|
127 | - $texte.= '</table>'; |
|
128 | - $texte.= '</form>'; |
|
129 | - |
|
130 | - return $texte; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Return an example of result returned by getNextValue |
|
136 | - * |
|
137 | - * @param Translate $langs Object langs |
|
138 | - * @param societe $objsoc Object thirdparty |
|
139 | - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
|
140 | - * @return string Return string example |
|
141 | - */ |
|
142 | - function getExample($langs,$objsoc=0,$type=-1) |
|
143 | - { |
|
144 | - if ($type == 0 || $type == -1) |
|
145 | - { |
|
146 | - $examplecust = $this->getNextValue($objsoc,0); |
|
147 | - if (! $examplecust) |
|
148 | - { |
|
149 | - $examplecust = $langs->trans('NotConfigured'); |
|
150 | - } |
|
151 | - if($examplecust=="ErrorBadMask") |
|
152 | - { |
|
153 | - $langs->load("errors"); |
|
154 | - $examplecust=$langs->trans($examplecust); |
|
155 | - } |
|
156 | - if($examplecust=="ErrorCantUseRazIfNoYearInMask") |
|
157 | - { |
|
158 | - $langs->load("errors"); |
|
159 | - $examplecust=$langs->trans($examplecust); |
|
160 | - } |
|
161 | - if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
162 | - { |
|
163 | - $langs->load("errors"); |
|
164 | - $examplecust=$langs->trans($examplecust); |
|
165 | - } |
|
166 | - } |
|
167 | - if ($type == 1 || $type == -1) |
|
168 | - { |
|
169 | - $examplesup = $this->getNextValue($objsoc,1); |
|
170 | - if (! $examplesup) |
|
171 | - { |
|
172 | - $examplesup = $langs->trans('NotConfigured'); |
|
173 | - } |
|
174 | - if($examplesup=="ErrorBadMask") |
|
175 | - { |
|
176 | - $langs->load("errors"); |
|
177 | - $examplesup=$langs->trans($examplesup); |
|
178 | - } |
|
179 | - if($examplesup=="ErrorCantUseRazIfNoYearInMask") |
|
180 | - { |
|
181 | - $langs->load("errors"); |
|
182 | - $examplesup=$langs->trans($examplesup); |
|
183 | - } |
|
184 | - if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
185 | - { |
|
186 | - $langs->load("errors"); |
|
187 | - $examplesup=$langs->trans($examplesup); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - if ($type == 0) return $examplecust; |
|
192 | - if ($type == 1) return $examplesup; |
|
193 | - return $examplecust.'<br>'.$examplesup; |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Return next value |
|
198 | - * |
|
199 | - * @param Societe $objsoc Object third party |
|
200 | - * @param int $type Client ou fournisseur (0:customer, 1:supplier) |
|
201 | - * @return string Value if OK, '' if module not configured, <0 if KO |
|
202 | - */ |
|
203 | - function getNextValue($objsoc=0,$type=-1) |
|
204 | - { |
|
205 | - global $db,$conf; |
|
206 | - |
|
207 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
208 | - |
|
209 | - // Get Mask value |
|
210 | - $mask = ''; |
|
211 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
213 | - if (! $mask) |
|
214 | - { |
|
215 | - $this->error='NotConfigured'; |
|
216 | - return ''; |
|
217 | - } |
|
218 | - |
|
219 | - $field='';$where=''; |
|
220 | - if ($type == 0) |
|
221 | - { |
|
222 | - $field = 'code_client'; |
|
223 | - //$where = ' AND client in (1,2)'; |
|
224 | - } |
|
225 | - else if ($type == 1) |
|
226 | - { |
|
227 | - $field = 'code_fournisseur'; |
|
228 | - //$where = ' AND fournisseur = 1'; |
|
229 | - } |
|
230 | - else return -1; |
|
231 | - |
|
232 | - $now=dol_now(); |
|
233 | - |
|
234 | - $numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now); |
|
235 | - |
|
236 | - return $numFinal; |
|
237 | - } |
|
61 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
62 | + |
|
63 | + public $code_auto; // Numerotation automatique |
|
64 | + |
|
65 | + public $searchcode; // String de recherche |
|
66 | + |
|
67 | + public $numbitcounter; // Nombre de chiffres du compteur |
|
68 | + |
|
69 | + public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * Constructor |
|
74 | + */ |
|
75 | + function __construct() |
|
76 | + { |
|
77 | + $this->code_null = 0; |
|
78 | + $this->code_modifiable = 1; |
|
79 | + $this->code_modifiable_invalide = 1; |
|
80 | + $this->code_modifiable_null = 1; |
|
81 | + $this->code_auto = 1; |
|
82 | + $this->prefixIsRequired = 0; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** Return description of module |
|
87 | + * |
|
88 | + * @param Translate $langs Object langs |
|
89 | + * @return string Description of module |
|
90 | + */ |
|
91 | + function info($langs) |
|
92 | + { |
|
93 | + global $conf, $mc; |
|
94 | + global $form; |
|
95 | + |
|
96 | + $langs->load("companies"); |
|
97 | + |
|
98 | + $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
99 | + |
|
100 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
101 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
102 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
103 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
104 | + $texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
105 | + $texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
106 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
107 | + |
|
108 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty")); |
|
109 | + //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering |
|
110 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
111 | + $tooltip.=$langs->trans("GenericMaskCodes4b"); |
|
112 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
113 | + |
|
114 | + // Parametrage du prefix customers |
|
115 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
116 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
117 | + |
|
118 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
119 | + |
|
120 | + $texte.= '</tr>'; |
|
121 | + |
|
122 | + // Parametrage du prefix suppliers |
|
123 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
124 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
125 | + $texte.= '</tr>'; |
|
126 | + |
|
127 | + $texte.= '</table>'; |
|
128 | + $texte.= '</form>'; |
|
129 | + |
|
130 | + return $texte; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Return an example of result returned by getNextValue |
|
136 | + * |
|
137 | + * @param Translate $langs Object langs |
|
138 | + * @param societe $objsoc Object thirdparty |
|
139 | + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
|
140 | + * @return string Return string example |
|
141 | + */ |
|
142 | + function getExample($langs,$objsoc=0,$type=-1) |
|
143 | + { |
|
144 | + if ($type == 0 || $type == -1) |
|
145 | + { |
|
146 | + $examplecust = $this->getNextValue($objsoc,0); |
|
147 | + if (! $examplecust) |
|
148 | + { |
|
149 | + $examplecust = $langs->trans('NotConfigured'); |
|
150 | + } |
|
151 | + if($examplecust=="ErrorBadMask") |
|
152 | + { |
|
153 | + $langs->load("errors"); |
|
154 | + $examplecust=$langs->trans($examplecust); |
|
155 | + } |
|
156 | + if($examplecust=="ErrorCantUseRazIfNoYearInMask") |
|
157 | + { |
|
158 | + $langs->load("errors"); |
|
159 | + $examplecust=$langs->trans($examplecust); |
|
160 | + } |
|
161 | + if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
162 | + { |
|
163 | + $langs->load("errors"); |
|
164 | + $examplecust=$langs->trans($examplecust); |
|
165 | + } |
|
166 | + } |
|
167 | + if ($type == 1 || $type == -1) |
|
168 | + { |
|
169 | + $examplesup = $this->getNextValue($objsoc,1); |
|
170 | + if (! $examplesup) |
|
171 | + { |
|
172 | + $examplesup = $langs->trans('NotConfigured'); |
|
173 | + } |
|
174 | + if($examplesup=="ErrorBadMask") |
|
175 | + { |
|
176 | + $langs->load("errors"); |
|
177 | + $examplesup=$langs->trans($examplesup); |
|
178 | + } |
|
179 | + if($examplesup=="ErrorCantUseRazIfNoYearInMask") |
|
180 | + { |
|
181 | + $langs->load("errors"); |
|
182 | + $examplesup=$langs->trans($examplesup); |
|
183 | + } |
|
184 | + if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
185 | + { |
|
186 | + $langs->load("errors"); |
|
187 | + $examplesup=$langs->trans($examplesup); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + if ($type == 0) return $examplecust; |
|
192 | + if ($type == 1) return $examplesup; |
|
193 | + return $examplecust.'<br>'.$examplesup; |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Return next value |
|
198 | + * |
|
199 | + * @param Societe $objsoc Object third party |
|
200 | + * @param int $type Client ou fournisseur (0:customer, 1:supplier) |
|
201 | + * @return string Value if OK, '' if module not configured, <0 if KO |
|
202 | + */ |
|
203 | + function getNextValue($objsoc=0,$type=-1) |
|
204 | + { |
|
205 | + global $db,$conf; |
|
206 | + |
|
207 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
208 | + |
|
209 | + // Get Mask value |
|
210 | + $mask = ''; |
|
211 | + if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | + if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
213 | + if (! $mask) |
|
214 | + { |
|
215 | + $this->error='NotConfigured'; |
|
216 | + return ''; |
|
217 | + } |
|
218 | + |
|
219 | + $field='';$where=''; |
|
220 | + if ($type == 0) |
|
221 | + { |
|
222 | + $field = 'code_client'; |
|
223 | + //$where = ' AND client in (1,2)'; |
|
224 | + } |
|
225 | + else if ($type == 1) |
|
226 | + { |
|
227 | + $field = 'code_fournisseur'; |
|
228 | + //$where = ' AND fournisseur = 1'; |
|
229 | + } |
|
230 | + else return -1; |
|
231 | + |
|
232 | + $now=dol_now(); |
|
233 | + |
|
234 | + $numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now); |
|
235 | + |
|
236 | + return $numFinal; |
|
237 | + } |
|
238 | 238 | |
239 | 239 | |
240 | 240 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
241 | - /** |
|
242 | - * Check if mask/numbering use prefix |
|
243 | - * |
|
244 | - * @return int 0 or 1 |
|
245 | - */ |
|
246 | - function verif_prefixIsUsed() |
|
247 | - { |
|
241 | + /** |
|
242 | + * Check if mask/numbering use prefix |
|
243 | + * |
|
244 | + * @return int 0 or 1 |
|
245 | + */ |
|
246 | + function verif_prefixIsUsed() |
|
247 | + { |
|
248 | 248 | // phpcs:enable |
249 | - global $conf; |
|
250 | - |
|
251 | - $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
252 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
253 | - |
|
254 | - $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
255 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
256 | - |
|
257 | - return 0; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * Check validity of code according to its rules |
|
263 | - * |
|
264 | - * @param DoliDB $db Database handler |
|
265 | - * @param string $code Code to check/correct |
|
266 | - * @param Societe $soc Object third party |
|
267 | - * @param int $type 0 = customer/prospect , 1 = supplier |
|
268 | - * @return int 0 if OK |
|
269 | - * -1 ErrorBadCustomerCodeSyntax |
|
270 | - * -2 ErrorCustomerCodeRequired |
|
271 | - * -3 ErrorCustomerCodeAlreadyUsed |
|
272 | - * -4 ErrorPrefixRequired |
|
273 | - * -5 Other (see this->error) |
|
274 | - */ |
|
275 | - function verif($db, &$code, $soc, $type) |
|
276 | - { |
|
277 | - global $conf; |
|
278 | - |
|
279 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
280 | - |
|
281 | - $result=0; |
|
282 | - $code = strtoupper(trim($code)); |
|
283 | - |
|
284 | - if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
|
285 | - { |
|
286 | - $result=0; |
|
287 | - } |
|
288 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
289 | - { |
|
290 | - $result=-2; |
|
291 | - } |
|
292 | - else |
|
293 | - { |
|
294 | - // Get Mask value |
|
295 | - $mask = ''; |
|
296 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
298 | - if (! $mask) |
|
299 | - { |
|
300 | - $this->error='NotConfigured'; |
|
301 | - return -5; |
|
302 | - } |
|
303 | - |
|
304 | - $result=check_value($mask,$code); |
|
305 | - if (is_string($result)) |
|
306 | - { |
|
307 | - $this->error = $result; |
|
308 | - return -5; |
|
309 | - } |
|
310 | - } |
|
311 | - |
|
312 | - dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result); |
|
313 | - return $result; |
|
314 | - } |
|
249 | + global $conf; |
|
250 | + |
|
251 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
252 | + if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
253 | + |
|
254 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
255 | + if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
256 | + |
|
257 | + return 0; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * Check validity of code according to its rules |
|
263 | + * |
|
264 | + * @param DoliDB $db Database handler |
|
265 | + * @param string $code Code to check/correct |
|
266 | + * @param Societe $soc Object third party |
|
267 | + * @param int $type 0 = customer/prospect , 1 = supplier |
|
268 | + * @return int 0 if OK |
|
269 | + * -1 ErrorBadCustomerCodeSyntax |
|
270 | + * -2 ErrorCustomerCodeRequired |
|
271 | + * -3 ErrorCustomerCodeAlreadyUsed |
|
272 | + * -4 ErrorPrefixRequired |
|
273 | + * -5 Other (see this->error) |
|
274 | + */ |
|
275 | + function verif($db, &$code, $soc, $type) |
|
276 | + { |
|
277 | + global $conf; |
|
278 | + |
|
279 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
280 | + |
|
281 | + $result=0; |
|
282 | + $code = strtoupper(trim($code)); |
|
283 | + |
|
284 | + if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
|
285 | + { |
|
286 | + $result=0; |
|
287 | + } |
|
288 | + else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
289 | + { |
|
290 | + $result=-2; |
|
291 | + } |
|
292 | + else |
|
293 | + { |
|
294 | + // Get Mask value |
|
295 | + $mask = ''; |
|
296 | + if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | + if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
298 | + if (! $mask) |
|
299 | + { |
|
300 | + $this->error='NotConfigured'; |
|
301 | + return -5; |
|
302 | + } |
|
303 | + |
|
304 | + $result=check_value($mask,$code); |
|
305 | + if (is_string($result)) |
|
306 | + { |
|
307 | + $this->error = $result; |
|
308 | + return -5; |
|
309 | + } |
|
310 | + } |
|
311 | + |
|
312 | + dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result); |
|
313 | + return $result; |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | 317 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
318 | - /** |
|
319 | - * Renvoi si un code est pris ou non (par autre tiers) |
|
320 | - * |
|
321 | - * @param DoliDB $db Handler acces base |
|
322 | - * @param string $code Code a verifier |
|
323 | - * @param Societe $soc Objet societe |
|
324 | - * @param int $type 0 = customer/prospect , 1 = supplier |
|
325 | - * @return int 0 if available, <0 if KO |
|
326 | - */ |
|
327 | - function verif_dispo($db, $code, $soc, $type=0) |
|
328 | - { |
|
318 | + /** |
|
319 | + * Renvoi si un code est pris ou non (par autre tiers) |
|
320 | + * |
|
321 | + * @param DoliDB $db Handler acces base |
|
322 | + * @param string $code Code a verifier |
|
323 | + * @param Societe $soc Objet societe |
|
324 | + * @param int $type 0 = customer/prospect , 1 = supplier |
|
325 | + * @return int 0 if available, <0 if KO |
|
326 | + */ |
|
327 | + function verif_dispo($db, $code, $soc, $type=0) |
|
328 | + { |
|
329 | 329 | // phpcs:enable |
330 | - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
|
331 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
332 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
333 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
334 | - |
|
335 | - $resql=$db->query($sql); |
|
336 | - if ($resql) |
|
337 | - { |
|
338 | - if ($db->num_rows($resql) == 0) |
|
339 | - { |
|
340 | - return 0; |
|
341 | - } |
|
342 | - else |
|
343 | - { |
|
344 | - return -1; |
|
345 | - } |
|
346 | - } |
|
347 | - else |
|
348 | - { |
|
349 | - return -2; |
|
350 | - } |
|
351 | - } |
|
330 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
|
331 | + if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
332 | + else $sql.= " WHERE code_client = '".$code."'"; |
|
333 | + if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
334 | + |
|
335 | + $resql=$db->query($sql); |
|
336 | + if ($resql) |
|
337 | + { |
|
338 | + if ($db->num_rows($resql) == 0) |
|
339 | + { |
|
340 | + return 0; |
|
341 | + } |
|
342 | + else |
|
343 | + { |
|
344 | + return -1; |
|
345 | + } |
|
346 | + } |
|
347 | + else |
|
348 | + { |
|
349 | + return -2; |
|
350 | + } |
|
351 | + } |
|
352 | 352 | } |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | * @deprecated |
40 | 40 | * @see name |
41 | 41 | */ |
42 | - public $nom='Elephant'; |
|
42 | + public $nom = 'Elephant'; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var string model name |
46 | 46 | */ |
47 | - public $name='Elephant'; |
|
47 | + public $name = 'Elephant'; |
|
48 | 48 | |
49 | - public $code_modifiable; // Code modifiable |
|
49 | + public $code_modifiable; // Code modifiable |
|
50 | 50 | |
51 | - public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
51 | + public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
52 | 52 | |
53 | - public $code_modifiable_null; // Code modifiables si il est null |
|
53 | + public $code_modifiable_null; // Code modifiables si il est null |
|
54 | 54 | |
55 | - public $code_null; // Code facultatif |
|
55 | + public $code_null; // Code facultatif |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Dolibarr version of the loaded document |
59 | 59 | * @public string |
60 | 60 | */ |
61 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
61 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
62 | 62 | |
63 | - public $code_auto; // Numerotation automatique |
|
63 | + public $code_auto; // Numerotation automatique |
|
64 | 64 | |
65 | 65 | public $searchcode; // String de recherche |
66 | 66 | |
@@ -95,37 +95,37 @@ discard block |
||
95 | 95 | |
96 | 96 | $langs->load("companies"); |
97 | 97 | |
98 | - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
98 | + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); |
|
99 | 99 | |
100 | 100 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
101 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
102 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
103 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
104 | - $texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
105 | - $texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
106 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
107 | - |
|
108 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty")); |
|
101 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
102 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
103 | + $texte .= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
104 | + $texte .= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">'; |
|
105 | + $texte .= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">'; |
|
106 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
107 | + |
|
108 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); |
|
109 | 109 | //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering |
110 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
111 | - $tooltip.=$langs->trans("GenericMaskCodes4b"); |
|
112 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
110 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
111 | + $tooltip .= $langs->trans("GenericMaskCodes4b"); |
|
112 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
113 | 113 | |
114 | 114 | // Parametrage du prefix customers |
115 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
116 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
115 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>'; |
|
116 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
117 | 117 | |
118 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
118 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>'; |
|
119 | 119 | |
120 | - $texte.= '</tr>'; |
|
120 | + $texte .= '</tr>'; |
|
121 | 121 | |
122 | 122 | // Parametrage du prefix suppliers |
123 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
124 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>'; |
|
125 | - $texte.= '</tr>'; |
|
123 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>'; |
|
124 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>'; |
|
125 | + $texte .= '</tr>'; |
|
126 | 126 | |
127 | - $texte.= '</table>'; |
|
128 | - $texte.= '</form>'; |
|
127 | + $texte .= '</table>'; |
|
128 | + $texte .= '</form>'; |
|
129 | 129 | |
130 | 130 | return $texte; |
131 | 131 | } |
@@ -139,52 +139,52 @@ discard block |
||
139 | 139 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
140 | 140 | * @return string Return string example |
141 | 141 | */ |
142 | - function getExample($langs,$objsoc=0,$type=-1) |
|
142 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
143 | 143 | { |
144 | 144 | if ($type == 0 || $type == -1) |
145 | 145 | { |
146 | - $examplecust = $this->getNextValue($objsoc,0); |
|
147 | - if (! $examplecust) |
|
146 | + $examplecust = $this->getNextValue($objsoc, 0); |
|
147 | + if (!$examplecust) |
|
148 | 148 | { |
149 | 149 | $examplecust = $langs->trans('NotConfigured'); |
150 | 150 | } |
151 | - if($examplecust=="ErrorBadMask") |
|
151 | + if ($examplecust == "ErrorBadMask") |
|
152 | 152 | { |
153 | 153 | $langs->load("errors"); |
154 | - $examplecust=$langs->trans($examplecust); |
|
154 | + $examplecust = $langs->trans($examplecust); |
|
155 | 155 | } |
156 | - if($examplecust=="ErrorCantUseRazIfNoYearInMask") |
|
156 | + if ($examplecust == "ErrorCantUseRazIfNoYearInMask") |
|
157 | 157 | { |
158 | 158 | $langs->load("errors"); |
159 | - $examplecust=$langs->trans($examplecust); |
|
159 | + $examplecust = $langs->trans($examplecust); |
|
160 | 160 | } |
161 | - if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
161 | + if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
162 | 162 | { |
163 | 163 | $langs->load("errors"); |
164 | - $examplecust=$langs->trans($examplecust); |
|
164 | + $examplecust = $langs->trans($examplecust); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | if ($type == 1 || $type == -1) |
168 | 168 | { |
169 | - $examplesup = $this->getNextValue($objsoc,1); |
|
170 | - if (! $examplesup) |
|
169 | + $examplesup = $this->getNextValue($objsoc, 1); |
|
170 | + if (!$examplesup) |
|
171 | 171 | { |
172 | 172 | $examplesup = $langs->trans('NotConfigured'); |
173 | 173 | } |
174 | - if($examplesup=="ErrorBadMask") |
|
174 | + if ($examplesup == "ErrorBadMask") |
|
175 | 175 | { |
176 | 176 | $langs->load("errors"); |
177 | - $examplesup=$langs->trans($examplesup); |
|
177 | + $examplesup = $langs->trans($examplesup); |
|
178 | 178 | } |
179 | - if($examplesup=="ErrorCantUseRazIfNoYearInMask") |
|
179 | + if ($examplesup == "ErrorCantUseRazIfNoYearInMask") |
|
180 | 180 | { |
181 | 181 | $langs->load("errors"); |
182 | - $examplesup=$langs->trans($examplesup); |
|
182 | + $examplesup = $langs->trans($examplesup); |
|
183 | 183 | } |
184 | - if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
184 | + if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") |
|
185 | 185 | { |
186 | 186 | $langs->load("errors"); |
187 | - $examplesup=$langs->trans($examplesup); |
|
187 | + $examplesup = $langs->trans($examplesup); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * @param int $type Client ou fournisseur (0:customer, 1:supplier) |
201 | 201 | * @return string Value if OK, '' if module not configured, <0 if KO |
202 | 202 | */ |
203 | - function getNextValue($objsoc=0,$type=-1) |
|
203 | + function getNextValue($objsoc = 0, $type = -1) |
|
204 | 204 | { |
205 | - global $db,$conf; |
|
205 | + global $db, $conf; |
|
206 | 206 | |
207 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
207 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
208 | 208 | |
209 | 209 | // Get Mask value |
210 | 210 | $mask = ''; |
211 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
213 | - if (! $mask) |
|
211 | + if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | + if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
213 | + if (!$mask) |
|
214 | 214 | { |
215 | - $this->error='NotConfigured'; |
|
215 | + $this->error = 'NotConfigured'; |
|
216 | 216 | return ''; |
217 | 217 | } |
218 | 218 | |
219 | - $field='';$where=''; |
|
219 | + $field = ''; $where = ''; |
|
220 | 220 | if ($type == 0) |
221 | 221 | { |
222 | 222 | $field = 'code_client'; |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | } |
230 | 230 | else return -1; |
231 | 231 | |
232 | - $now=dol_now(); |
|
232 | + $now = dol_now(); |
|
233 | 233 | |
234 | - $numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now); |
|
234 | + $numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now); |
|
235 | 235 | |
236 | 236 | return $numFinal; |
237 | 237 | } |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | global $conf; |
250 | 250 | |
251 | 251 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
252 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
252 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
253 | 253 | |
254 | 254 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
255 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
255 | + if (preg_match('/\{pre\}/i', $mask)) return 1; |
|
256 | 256 | |
257 | 257 | return 0; |
258 | 258 | } |
@@ -276,32 +276,32 @@ discard block |
||
276 | 276 | { |
277 | 277 | global $conf; |
278 | 278 | |
279 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
279 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
280 | 280 | |
281 | - $result=0; |
|
281 | + $result = 0; |
|
282 | 282 | $code = strtoupper(trim($code)); |
283 | 283 | |
284 | 284 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
285 | 285 | { |
286 | - $result=0; |
|
286 | + $result = 0; |
|
287 | 287 | } |
288 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
288 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
289 | 289 | { |
290 | - $result=-2; |
|
290 | + $result = -2; |
|
291 | 291 | } |
292 | 292 | else |
293 | 293 | { |
294 | 294 | // Get Mask value |
295 | 295 | $mask = ''; |
296 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
298 | - if (! $mask) |
|
296 | + if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | + if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
298 | + if (!$mask) |
|
299 | 299 | { |
300 | - $this->error='NotConfigured'; |
|
300 | + $this->error = 'NotConfigured'; |
|
301 | 301 | return -5; |
302 | 302 | } |
303 | 303 | |
304 | - $result=check_value($mask,$code); |
|
304 | + $result = check_value($mask, $code); |
|
305 | 305 | if (is_string($result)) |
306 | 306 | { |
307 | 307 | $this->error = $result; |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | * @param int $type 0 = customer/prospect , 1 = supplier |
325 | 325 | * @return int 0 if available, <0 if KO |
326 | 326 | */ |
327 | - function verif_dispo($db, $code, $soc, $type=0) |
|
327 | + function verif_dispo($db, $code, $soc, $type = 0) |
|
328 | 328 | { |
329 | 329 | // phpcs:enable |
330 | 330 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
331 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
332 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
333 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
331 | + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; |
|
332 | + else $sql .= " WHERE code_client = '".$code."'"; |
|
333 | + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; |
|
334 | 334 | |
335 | - $resql=$db->query($sql); |
|
335 | + $resql = $db->query($sql); |
|
336 | 336 | if ($resql) |
337 | 337 | { |
338 | 338 | if ($db->num_rows($resql) == 0) |
@@ -188,8 +188,12 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if ($type == 0) return $examplecust; |
|
192 | - if ($type == 1) return $examplesup; |
|
191 | + if ($type == 0) { |
|
192 | + return $examplecust; |
|
193 | + } |
|
194 | + if ($type == 1) { |
|
195 | + return $examplesup; |
|
196 | + } |
|
193 | 197 | return $examplecust.'<br>'.$examplesup; |
194 | 198 | } |
195 | 199 | |
@@ -208,8 +212,12 @@ discard block |
||
208 | 212 | |
209 | 213 | // Get Mask value |
210 | 214 | $mask = ''; |
211 | - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
212 | - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
215 | + if ($type==0) { |
|
216 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
217 | + } |
|
218 | + if ($type==1) { |
|
219 | + $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
220 | + } |
|
213 | 221 | if (! $mask) |
214 | 222 | { |
215 | 223 | $this->error='NotConfigured'; |
@@ -221,13 +229,13 @@ discard block |
||
221 | 229 | { |
222 | 230 | $field = 'code_client'; |
223 | 231 | //$where = ' AND client in (1,2)'; |
224 | - } |
|
225 | - else if ($type == 1) |
|
232 | + } else if ($type == 1) |
|
226 | 233 | { |
227 | 234 | $field = 'code_fournisseur'; |
228 | 235 | //$where = ' AND fournisseur = 1'; |
236 | + } else { |
|
237 | + return -1; |
|
229 | 238 | } |
230 | - else return -1; |
|
231 | 239 | |
232 | 240 | $now=dol_now(); |
233 | 241 | |
@@ -249,10 +257,14 @@ discard block |
||
249 | 257 | global $conf; |
250 | 258 | |
251 | 259 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
252 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
260 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
261 | + return 1; |
|
262 | + } |
|
253 | 263 | |
254 | 264 | $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
255 | - if (preg_match('/\{pre\}/i',$mask)) return 1; |
|
265 | + if (preg_match('/\{pre\}/i',$mask)) { |
|
266 | + return 1; |
|
267 | + } |
|
256 | 268 | |
257 | 269 | return 0; |
258 | 270 | } |
@@ -284,17 +296,19 @@ discard block |
||
284 | 296 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
285 | 297 | { |
286 | 298 | $result=0; |
287 | - } |
|
288 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
299 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
289 | 300 | { |
290 | 301 | $result=-2; |
291 | - } |
|
292 | - else |
|
302 | + } else |
|
293 | 303 | { |
294 | 304 | // Get Mask value |
295 | 305 | $mask = ''; |
296 | - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
297 | - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
306 | + if ($type==0) { |
|
307 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; |
|
308 | + } |
|
309 | + if ($type==1) { |
|
310 | + $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; |
|
311 | + } |
|
298 | 312 | if (! $mask) |
299 | 313 | { |
300 | 314 | $this->error='NotConfigured'; |
@@ -328,9 +342,14 @@ discard block |
||
328 | 342 | { |
329 | 343 | // phpcs:enable |
330 | 344 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
331 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
332 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
333 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
345 | + if ($type == 1) { |
|
346 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
347 | + } else { |
|
348 | + $sql.= " WHERE code_client = '".$code."'"; |
|
349 | + } |
|
350 | + if ($soc->id > 0) { |
|
351 | + $sql.= " AND rowid <> ".$soc->id; |
|
352 | + } |
|
334 | 353 | |
335 | 354 | $resql=$db->query($sql); |
336 | 355 | if ($resql) |
@@ -338,13 +357,11 @@ discard block |
||
338 | 357 | if ($db->num_rows($resql) == 0) |
339 | 358 | { |
340 | 359 | return 0; |
341 | - } |
|
342 | - else |
|
360 | + } else |
|
343 | 361 | { |
344 | 362 | return -1; |
345 | 363 | } |
346 | - } |
|
347 | - else |
|
364 | + } else |
|
348 | 365 | { |
349 | 366 | return -2; |
350 | 367 | } |
@@ -32,259 +32,259 @@ |
||
32 | 32 | */ |
33 | 33 | class mod_codeclient_monkey extends ModeleThirdPartyCode |
34 | 34 | { |
35 | - /** |
|
36 | - * @var string Nom du modele |
|
37 | - * @deprecated |
|
38 | - * @see name |
|
39 | - */ |
|
40 | - public $nom='Monkey'; |
|
35 | + /** |
|
36 | + * @var string Nom du modele |
|
37 | + * @deprecated |
|
38 | + * @see name |
|
39 | + */ |
|
40 | + public $nom='Monkey'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var string model name |
|
44 | - */ |
|
45 | - public $name='Monkey'; |
|
42 | + /** |
|
43 | + * @var string model name |
|
44 | + */ |
|
45 | + public $name='Monkey'; |
|
46 | 46 | |
47 | - public $code_modifiable; // Code modifiable |
|
47 | + public $code_modifiable; // Code modifiable |
|
48 | 48 | |
49 | - public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
49 | + public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
50 | 50 | |
51 | - public $code_modifiable_null; // Code modifiables si il est null |
|
51 | + public $code_modifiable_null; // Code modifiables si il est null |
|
52 | 52 | |
53 | - public $code_null; // Code facultatif |
|
53 | + public $code_null; // Code facultatif |
|
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * Dolibarr version of the loaded document |
57 | 57 | * @public string |
58 | 58 | */ |
59 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | - |
|
61 | - public $code_auto; // Numerotation automatique |
|
62 | - |
|
63 | - public $prefixcustomer='CU'; |
|
64 | - |
|
65 | - public $prefixsupplier='SU'; |
|
66 | - |
|
67 | - public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Constructor |
|
72 | - */ |
|
73 | - function __construct() |
|
74 | - { |
|
75 | - $this->nom = "Monkey"; |
|
76 | - $this->name = "Monkey"; |
|
77 | - $this->version = "dolibarr"; |
|
78 | - $this->code_null = 1; |
|
79 | - $this->code_modifiable = 1; |
|
80 | - $this->code_modifiable_invalide = 1; |
|
81 | - $this->code_modifiable_null = 1; |
|
82 | - $this->code_auto = 1; |
|
83 | - $this->prefixIsRequired = 0; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** Return description of module |
|
88 | - * |
|
89 | - * @param Translate $langs Object langs |
|
90 | - * @return string Description of module |
|
91 | - */ |
|
92 | - function info($langs) |
|
93 | - { |
|
94 | - return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * Return an example of result returned by getNextValue |
|
100 | - * |
|
101 | - * @param Translate $langs Object langs |
|
102 | - * @param societe $objsoc Object thirdparty |
|
103 | - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
|
104 | - * @return string Return string example |
|
105 | - */ |
|
106 | - function getExample($langs,$objsoc=0,$type=-1) |
|
107 | - { |
|
108 | - return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001'; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * Return next value |
|
114 | - * |
|
115 | - * @param Societe $objsoc Object third party |
|
116 | - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) |
|
117 | - * @return string Value if OK, '' if module not configured, <0 if KO |
|
118 | - */ |
|
119 | - function getNextValue($objsoc=0,$type=-1) |
|
120 | - { |
|
121 | - global $db, $conf, $mc; |
|
122 | - |
|
123 | - $field=''; |
|
59 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | + |
|
61 | + public $code_auto; // Numerotation automatique |
|
62 | + |
|
63 | + public $prefixcustomer='CU'; |
|
64 | + |
|
65 | + public $prefixsupplier='SU'; |
|
66 | + |
|
67 | + public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Constructor |
|
72 | + */ |
|
73 | + function __construct() |
|
74 | + { |
|
75 | + $this->nom = "Monkey"; |
|
76 | + $this->name = "Monkey"; |
|
77 | + $this->version = "dolibarr"; |
|
78 | + $this->code_null = 1; |
|
79 | + $this->code_modifiable = 1; |
|
80 | + $this->code_modifiable_invalide = 1; |
|
81 | + $this->code_modifiable_null = 1; |
|
82 | + $this->code_auto = 1; |
|
83 | + $this->prefixIsRequired = 0; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** Return description of module |
|
88 | + * |
|
89 | + * @param Translate $langs Object langs |
|
90 | + * @return string Description of module |
|
91 | + */ |
|
92 | + function info($langs) |
|
93 | + { |
|
94 | + return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * Return an example of result returned by getNextValue |
|
100 | + * |
|
101 | + * @param Translate $langs Object langs |
|
102 | + * @param societe $objsoc Object thirdparty |
|
103 | + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
|
104 | + * @return string Return string example |
|
105 | + */ |
|
106 | + function getExample($langs,$objsoc=0,$type=-1) |
|
107 | + { |
|
108 | + return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001'; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * Return next value |
|
114 | + * |
|
115 | + * @param Societe $objsoc Object third party |
|
116 | + * @param int $type Client ou fournisseur (1:client, 2:fournisseur) |
|
117 | + * @return string Value if OK, '' if module not configured, <0 if KO |
|
118 | + */ |
|
119 | + function getNextValue($objsoc=0,$type=-1) |
|
120 | + { |
|
121 | + global $db, $conf, $mc; |
|
122 | + |
|
123 | + $field=''; |
|
124 | 124 | $prefix = ''; |
125 | - if ($type == 0) { |
|
126 | - $field = 'code_client'; |
|
125 | + if ($type == 0) { |
|
126 | + $field = 'code_client'; |
|
127 | 127 | $prefix = $this->prefixcustomer; |
128 | - } elseif ($type == 1) { |
|
129 | - $field = 'code_fournisseur'; |
|
128 | + } elseif ($type == 1) { |
|
129 | + $field = 'code_fournisseur'; |
|
130 | 130 | $prefix = $this->prefixsupplier; |
131 | - } else { |
|
131 | + } else { |
|
132 | 132 | return -1; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // D'abord on recupere la valeur max (reponse immediate car champ indexe) |
136 | - $posindice=8; |
|
136 | + $posindice=8; |
|
137 | 137 | $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
138 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
|
139 | - $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
140 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
141 | - |
|
142 | - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
143 | - |
|
144 | - $resql=$db->query($sql); |
|
145 | - if ($resql) |
|
146 | - { |
|
147 | - $obj = $db->fetch_object($resql); |
|
148 | - if ($obj) $max = intval($obj->max); |
|
149 | - else $max=0; |
|
150 | - } |
|
151 | - else |
|
152 | - { |
|
153 | - return -1; |
|
154 | - } |
|
155 | - |
|
156 | - $date = dol_now(); |
|
157 | - $yymm = strftime("%y%m",$date); |
|
158 | - |
|
159 | - if ($max >= (pow(10, 5) - 1)) $num=$max+1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | - else $num = sprintf("%05s",$max+1); |
|
161 | - |
|
162 | - dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
163 | - return $prefix.$yymm."-".$num; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Check validity of code according to its rules |
|
169 | - * |
|
170 | - * @param DoliDB $db Database handler |
|
171 | - * @param string $code Code to check/correct |
|
172 | - * @param Societe $soc Object third party |
|
173 | - * @param int $type 0 = customer/prospect , 1 = supplier |
|
174 | - * @return int 0 if OK |
|
175 | - * -1 ErrorBadCustomerCodeSyntax |
|
176 | - * -2 ErrorCustomerCodeRequired |
|
177 | - * -3 ErrorCustomerCodeAlreadyUsed |
|
178 | - * -4 ErrorPrefixRequired |
|
179 | - */ |
|
180 | - function verif($db, &$code, $soc, $type) |
|
181 | - { |
|
182 | - global $conf; |
|
183 | - |
|
184 | - $result=0; |
|
185 | - $code = strtoupper(trim($code)); |
|
186 | - |
|
187 | - if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
|
188 | - { |
|
189 | - $result=0; |
|
190 | - } |
|
191 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
192 | - { |
|
193 | - $result=-2; |
|
194 | - } |
|
195 | - else |
|
196 | - { |
|
197 | - if ($this->verif_syntax($code) >= 0) |
|
198 | - { |
|
199 | - $is_dispo = $this->verif_dispo($db, $code, $soc, $type); |
|
200 | - if ($is_dispo <> 0) |
|
201 | - { |
|
202 | - $result=-3; |
|
203 | - } |
|
204 | - else |
|
205 | - { |
|
206 | - $result=0; |
|
207 | - } |
|
208 | - } |
|
209 | - else |
|
210 | - { |
|
211 | - if (dol_strlen($code) == 0) |
|
212 | - { |
|
213 | - $result=-2; |
|
214 | - } |
|
215 | - else |
|
216 | - { |
|
217 | - $result=-1; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - dol_syslog(get_class($this)."::verif code=".$code." type=".$type." result=".$result); |
|
223 | - return $result; |
|
224 | - } |
|
138 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
|
139 | + $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
140 | + $sql.= " AND entity IN (".getEntity('societe').")"; |
|
141 | + |
|
142 | + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
143 | + |
|
144 | + $resql=$db->query($sql); |
|
145 | + if ($resql) |
|
146 | + { |
|
147 | + $obj = $db->fetch_object($resql); |
|
148 | + if ($obj) $max = intval($obj->max); |
|
149 | + else $max=0; |
|
150 | + } |
|
151 | + else |
|
152 | + { |
|
153 | + return -1; |
|
154 | + } |
|
155 | + |
|
156 | + $date = dol_now(); |
|
157 | + $yymm = strftime("%y%m",$date); |
|
158 | + |
|
159 | + if ($max >= (pow(10, 5) - 1)) $num=$max+1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | + else $num = sprintf("%05s",$max+1); |
|
161 | + |
|
162 | + dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
163 | + return $prefix.$yymm."-".$num; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Check validity of code according to its rules |
|
169 | + * |
|
170 | + * @param DoliDB $db Database handler |
|
171 | + * @param string $code Code to check/correct |
|
172 | + * @param Societe $soc Object third party |
|
173 | + * @param int $type 0 = customer/prospect , 1 = supplier |
|
174 | + * @return int 0 if OK |
|
175 | + * -1 ErrorBadCustomerCodeSyntax |
|
176 | + * -2 ErrorCustomerCodeRequired |
|
177 | + * -3 ErrorCustomerCodeAlreadyUsed |
|
178 | + * -4 ErrorPrefixRequired |
|
179 | + */ |
|
180 | + function verif($db, &$code, $soc, $type) |
|
181 | + { |
|
182 | + global $conf; |
|
183 | + |
|
184 | + $result=0; |
|
185 | + $code = strtoupper(trim($code)); |
|
186 | + |
|
187 | + if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
|
188 | + { |
|
189 | + $result=0; |
|
190 | + } |
|
191 | + else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
192 | + { |
|
193 | + $result=-2; |
|
194 | + } |
|
195 | + else |
|
196 | + { |
|
197 | + if ($this->verif_syntax($code) >= 0) |
|
198 | + { |
|
199 | + $is_dispo = $this->verif_dispo($db, $code, $soc, $type); |
|
200 | + if ($is_dispo <> 0) |
|
201 | + { |
|
202 | + $result=-3; |
|
203 | + } |
|
204 | + else |
|
205 | + { |
|
206 | + $result=0; |
|
207 | + } |
|
208 | + } |
|
209 | + else |
|
210 | + { |
|
211 | + if (dol_strlen($code) == 0) |
|
212 | + { |
|
213 | + $result=-2; |
|
214 | + } |
|
215 | + else |
|
216 | + { |
|
217 | + $result=-1; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + dol_syslog(get_class($this)."::verif code=".$code." type=".$type." result=".$result); |
|
223 | + return $result; |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | 227 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
228 | - /** |
|
229 | - * Renvoi si un code est pris ou non (par autre tiers) |
|
230 | - * |
|
231 | - * @param DoliDB $db Handler acces base |
|
232 | - * @param string $code Code a verifier |
|
233 | - * @param Societe $soc Objet societe |
|
234 | - * @param int $type 0 = customer/prospect , 1 = supplier |
|
235 | - * @return int 0 if available, <0 if KO |
|
236 | - */ |
|
237 | - function verif_dispo($db, $code, $soc, $type=0) |
|
238 | - { |
|
228 | + /** |
|
229 | + * Renvoi si un code est pris ou non (par autre tiers) |
|
230 | + * |
|
231 | + * @param DoliDB $db Handler acces base |
|
232 | + * @param string $code Code a verifier |
|
233 | + * @param Societe $soc Objet societe |
|
234 | + * @param int $type 0 = customer/prospect , 1 = supplier |
|
235 | + * @return int 0 if available, <0 if KO |
|
236 | + */ |
|
237 | + function verif_dispo($db, $code, $soc, $type=0) |
|
238 | + { |
|
239 | 239 | // phpcs:enable |
240 | - global $conf, $mc; |
|
241 | - |
|
242 | - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
|
243 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
244 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
245 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
246 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
247 | - |
|
248 | - dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
|
249 | - $resql=$db->query($sql); |
|
250 | - if ($resql) |
|
251 | - { |
|
252 | - if ($db->num_rows($resql) == 0) |
|
253 | - { |
|
254 | - return 0; |
|
255 | - } |
|
256 | - else |
|
257 | - { |
|
258 | - return -1; |
|
259 | - } |
|
260 | - } |
|
261 | - else |
|
262 | - { |
|
263 | - return -2; |
|
264 | - } |
|
265 | - } |
|
240 | + global $conf, $mc; |
|
241 | + |
|
242 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
|
243 | + if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
244 | + else $sql.= " WHERE code_client = '".$code."'"; |
|
245 | + $sql.= " AND entity IN (".getEntity('societe').")"; |
|
246 | + if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
247 | + |
|
248 | + dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
|
249 | + $resql=$db->query($sql); |
|
250 | + if ($resql) |
|
251 | + { |
|
252 | + if ($db->num_rows($resql) == 0) |
|
253 | + { |
|
254 | + return 0; |
|
255 | + } |
|
256 | + else |
|
257 | + { |
|
258 | + return -1; |
|
259 | + } |
|
260 | + } |
|
261 | + else |
|
262 | + { |
|
263 | + return -2; |
|
264 | + } |
|
265 | + } |
|
266 | 266 | |
267 | 267 | |
268 | 268 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
269 | - /** |
|
270 | - * Renvoi si un code respecte la syntaxe |
|
271 | - * |
|
272 | - * @param string $code Code a verifier |
|
273 | - * @return int 0 si OK, <0 si KO |
|
274 | - */ |
|
275 | - function verif_syntax($code) |
|
276 | - { |
|
269 | + /** |
|
270 | + * Renvoi si un code respecte la syntaxe |
|
271 | + * |
|
272 | + * @param string $code Code a verifier |
|
273 | + * @return int 0 si OK, <0 si KO |
|
274 | + */ |
|
275 | + function verif_syntax($code) |
|
276 | + { |
|
277 | 277 | // phpcs:enable |
278 | - $res = 0; |
|
279 | - |
|
280 | - if (dol_strlen($code) < 11) |
|
281 | - { |
|
282 | - $res = -1; |
|
283 | - } |
|
284 | - else |
|
285 | - { |
|
286 | - $res = 0; |
|
287 | - } |
|
288 | - return $res; |
|
289 | - } |
|
278 | + $res = 0; |
|
279 | + |
|
280 | + if (dol_strlen($code) < 11) |
|
281 | + { |
|
282 | + $res = -1; |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
286 | + $res = 0; |
|
287 | + } |
|
288 | + return $res; |
|
289 | + } |
|
290 | 290 | } |
@@ -37,32 +37,32 @@ discard block |
||
37 | 37 | * @deprecated |
38 | 38 | * @see name |
39 | 39 | */ |
40 | - public $nom='Monkey'; |
|
40 | + public $nom = 'Monkey'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string model name |
44 | 44 | */ |
45 | - public $name='Monkey'; |
|
45 | + public $name = 'Monkey'; |
|
46 | 46 | |
47 | - public $code_modifiable; // Code modifiable |
|
47 | + public $code_modifiable; // Code modifiable |
|
48 | 48 | |
49 | - public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
49 | + public $code_modifiable_invalide; // Code modifiable si il est invalide |
|
50 | 50 | |
51 | - public $code_modifiable_null; // Code modifiables si il est null |
|
51 | + public $code_modifiable_null; // Code modifiables si il est null |
|
52 | 52 | |
53 | - public $code_null; // Code facultatif |
|
53 | + public $code_null; // Code facultatif |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Dolibarr version of the loaded document |
57 | 57 | * @public string |
58 | 58 | */ |
59 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
59 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
60 | 60 | |
61 | - public $code_auto; // Numerotation automatique |
|
61 | + public $code_auto; // Numerotation automatique |
|
62 | 62 | |
63 | - public $prefixcustomer='CU'; |
|
63 | + public $prefixcustomer = 'CU'; |
|
64 | 64 | |
65 | - public $prefixsupplier='SU'; |
|
65 | + public $prefixsupplier = 'SU'; |
|
66 | 66 | |
67 | 67 | public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} |
68 | 68 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function info($langs) |
93 | 93 | { |
94 | - return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier); |
|
94 | + return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
104 | 104 | * @return string Return string example |
105 | 105 | */ |
106 | - function getExample($langs,$objsoc=0,$type=-1) |
|
106 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
107 | 107 | { |
108 | 108 | return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001'; |
109 | 109 | } |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @param int $type Client ou fournisseur (1:client, 2:fournisseur) |
117 | 117 | * @return string Value if OK, '' if module not configured, <0 if KO |
118 | 118 | */ |
119 | - function getNextValue($objsoc=0,$type=-1) |
|
119 | + function getNextValue($objsoc = 0, $type = -1) |
|
120 | 120 | { |
121 | 121 | global $db, $conf, $mc; |
122 | 122 | |
123 | - $field=''; |
|
123 | + $field = ''; |
|
124 | 124 | $prefix = ''; |
125 | 125 | if ($type == 0) { |
126 | 126 | $field = 'code_client'; |
@@ -133,20 +133,20 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // D'abord on recupere la valeur max (reponse immediate car champ indexe) |
136 | - $posindice=8; |
|
137 | - $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
138 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
|
139 | - $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
140 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
136 | + $posindice = 8; |
|
137 | + $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
138 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; |
|
139 | + $sql .= " WHERE ".$field." LIKE '".$prefix."____-%'"; |
|
140 | + $sql .= " AND entity IN (".getEntity('societe').")"; |
|
141 | 141 | |
142 | 142 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
143 | 143 | |
144 | - $resql=$db->query($sql); |
|
144 | + $resql = $db->query($sql); |
|
145 | 145 | if ($resql) |
146 | 146 | { |
147 | 147 | $obj = $db->fetch_object($resql); |
148 | 148 | if ($obj) $max = intval($obj->max); |
149 | - else $max=0; |
|
149 | + else $max = 0; |
|
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | $date = dol_now(); |
157 | - $yymm = strftime("%y%m",$date); |
|
157 | + $yymm = strftime("%y%m", $date); |
|
158 | 158 | |
159 | - if ($max >= (pow(10, 5) - 1)) $num=$max+1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | - else $num = sprintf("%05s",$max+1); |
|
159 | + if ($max >= (pow(10, 5) - 1)) $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | + else $num = sprintf("%05s", $max + 1); |
|
161 | 161 | |
162 | 162 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
163 | 163 | return $prefix.$yymm."-".$num; |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | { |
182 | 182 | global $conf; |
183 | 183 | |
184 | - $result=0; |
|
184 | + $result = 0; |
|
185 | 185 | $code = strtoupper(trim($code)); |
186 | 186 | |
187 | 187 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
188 | 188 | { |
189 | - $result=0; |
|
189 | + $result = 0; |
|
190 | 190 | } |
191 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
191 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
192 | 192 | { |
193 | - $result=-2; |
|
193 | + $result = -2; |
|
194 | 194 | } |
195 | 195 | else |
196 | 196 | { |
@@ -199,22 +199,22 @@ discard block |
||
199 | 199 | $is_dispo = $this->verif_dispo($db, $code, $soc, $type); |
200 | 200 | if ($is_dispo <> 0) |
201 | 201 | { |
202 | - $result=-3; |
|
202 | + $result = -3; |
|
203 | 203 | } |
204 | 204 | else |
205 | 205 | { |
206 | - $result=0; |
|
206 | + $result = 0; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | else |
210 | 210 | { |
211 | 211 | if (dol_strlen($code) == 0) |
212 | 212 | { |
213 | - $result=-2; |
|
213 | + $result = -2; |
|
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
217 | - $result=-1; |
|
217 | + $result = -1; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | * @param int $type 0 = customer/prospect , 1 = supplier |
235 | 235 | * @return int 0 if available, <0 if KO |
236 | 236 | */ |
237 | - function verif_dispo($db, $code, $soc, $type=0) |
|
237 | + function verif_dispo($db, $code, $soc, $type = 0) |
|
238 | 238 | { |
239 | 239 | // phpcs:enable |
240 | 240 | global $conf, $mc; |
241 | 241 | |
242 | 242 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
243 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
244 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
245 | - $sql.= " AND entity IN (".getEntity('societe').")"; |
|
246 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
243 | + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; |
|
244 | + else $sql .= " WHERE code_client = '".$code."'"; |
|
245 | + $sql .= " AND entity IN (".getEntity('societe').")"; |
|
246 | + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; |
|
247 | 247 | |
248 | 248 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
249 | - $resql=$db->query($sql); |
|
249 | + $resql = $db->query($sql); |
|
250 | 250 | if ($resql) |
251 | 251 | { |
252 | 252 | if ($db->num_rows($resql) == 0) |
@@ -145,10 +145,12 @@ discard block |
||
145 | 145 | if ($resql) |
146 | 146 | { |
147 | 147 | $obj = $db->fetch_object($resql); |
148 | - if ($obj) $max = intval($obj->max); |
|
149 | - else $max=0; |
|
150 | - } |
|
151 | - else |
|
148 | + if ($obj) { |
|
149 | + $max = intval($obj->max); |
|
150 | + } else { |
|
151 | + $max=0; |
|
152 | + } |
|
153 | + } else |
|
152 | 154 | { |
153 | 155 | return -1; |
154 | 156 | } |
@@ -156,8 +158,13 @@ discard block |
||
156 | 158 | $date = dol_now(); |
157 | 159 | $yymm = strftime("%y%m",$date); |
158 | 160 | |
159 | - if ($max >= (pow(10, 5) - 1)) $num=$max+1; // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
160 | - else $num = sprintf("%05s",$max+1); |
|
161 | + if ($max >= (pow(10, 5) - 1)) { |
|
162 | + $num=$max+1; |
|
163 | + } |
|
164 | + // If counter > 99999, we do not format on 5 chars, we take number as it is |
|
165 | + else { |
|
166 | + $num = sprintf("%05s",$max+1); |
|
167 | + } |
|
161 | 168 | |
162 | 169 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
163 | 170 | return $prefix.$yymm."-".$num; |
@@ -187,12 +194,10 @@ discard block |
||
187 | 194 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
188 | 195 | { |
189 | 196 | $result=0; |
190 | - } |
|
191 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
197 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
192 | 198 | { |
193 | 199 | $result=-2; |
194 | - } |
|
195 | - else |
|
200 | + } else |
|
196 | 201 | { |
197 | 202 | if ($this->verif_syntax($code) >= 0) |
198 | 203 | { |
@@ -200,19 +205,16 @@ discard block |
||
200 | 205 | if ($is_dispo <> 0) |
201 | 206 | { |
202 | 207 | $result=-3; |
203 | - } |
|
204 | - else |
|
208 | + } else |
|
205 | 209 | { |
206 | 210 | $result=0; |
207 | 211 | } |
208 | - } |
|
209 | - else |
|
212 | + } else |
|
210 | 213 | { |
211 | 214 | if (dol_strlen($code) == 0) |
212 | 215 | { |
213 | 216 | $result=-2; |
214 | - } |
|
215 | - else |
|
217 | + } else |
|
216 | 218 | { |
217 | 219 | $result=-1; |
218 | 220 | } |
@@ -240,10 +242,15 @@ discard block |
||
240 | 242 | global $conf, $mc; |
241 | 243 | |
242 | 244 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; |
243 | - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
244 | - else $sql.= " WHERE code_client = '".$code."'"; |
|
245 | + if ($type == 1) { |
|
246 | + $sql.= " WHERE code_fournisseur = '".$code."'"; |
|
247 | + } else { |
|
248 | + $sql.= " WHERE code_client = '".$code."'"; |
|
249 | + } |
|
245 | 250 | $sql.= " AND entity IN (".getEntity('societe').")"; |
246 | - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; |
|
251 | + if ($soc->id > 0) { |
|
252 | + $sql.= " AND rowid <> ".$soc->id; |
|
253 | + } |
|
247 | 254 | |
248 | 255 | dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG); |
249 | 256 | $resql=$db->query($sql); |
@@ -252,13 +259,11 @@ discard block |
||
252 | 259 | if ($db->num_rows($resql) == 0) |
253 | 260 | { |
254 | 261 | return 0; |
255 | - } |
|
256 | - else |
|
262 | + } else |
|
257 | 263 | { |
258 | 264 | return -1; |
259 | 265 | } |
260 | - } |
|
261 | - else |
|
266 | + } else |
|
262 | 267 | { |
263 | 268 | return -2; |
264 | 269 | } |
@@ -280,8 +285,7 @@ discard block |
||
280 | 285 | if (dol_strlen($code) < 11) |
281 | 286 | { |
282 | 287 | $res = -1; |
283 | - } |
|
284 | - else |
|
288 | + } else |
|
285 | 289 | { |
286 | 290 | $res = 0; |
287 | 291 | } |
@@ -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 | } |