dolibarr  13.0.2
societe.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4  * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32 
33 $langs->loadLangs(array("admin", "companies", "other"));
34 
35 $action = GETPOST('action', 'aZ09');
36 $value = GETPOST('value', 'alpha');
37 
38 if (!$user->admin) accessforbidden();
39 
40 $formcompany = new FormCompany($db);
41 
42 
43 
44 /*
45  * Actions
46  */
47 
48 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
49 
50 if ($action == 'setcodeclient')
51 {
52  if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
53  {
54  header("Location: ".$_SERVER["PHP_SELF"]);
55  exit;
56  } else {
57  dol_print_error($db);
58  }
59 }
60 
61 if ($action == 'setcodecompta')
62 {
63  if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0)
64  {
65  header("Location: ".$_SERVER["PHP_SELF"]);
66  exit;
67  } else {
68  dol_print_error($db);
69  }
70 }
71 
72 if ($action == 'updateoptions')
73 {
74  if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT'))
75  {
76  $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
77  $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
78  if (!($res > 0)) $error++;
79  if (!$error)
80  {
81  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
82  } else {
83  setEventMessages($langs->trans("Error"), null, 'errors');
84  }
85  }
86 
87  if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT'))
88  {
89  $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
90  $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
91  if (!($res > 0)) $error++;
92  if (!$error)
93  {
94  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
95  } else {
96  setEventMessages($langs->trans("Error"), null, 'errors');
97  }
98  }
99 
100  if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'))
101  {
102  $customertypedefault = GETPOST('defaultcustomertype', 'int');
103  $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
104  if (!($res > 0)) $error++;
105  if (!$error)
106  {
107  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
108  } else {
109  setEventMessages($langs->trans("Error"), null, 'errors');
110  }
111  }
112 }
113 
114 // Activate a document generator module
115 if ($action == 'set')
116 {
117  $label = GETPOST('label', 'alpha');
118  $scandir = GETPOST('scan_dir', 'alpha');
119 
120  $type = 'company';
121  $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
122  $sql .= " VALUES ('".$db->escape($value)."','".$db->escape($type)."',".$conf->entity.", ";
123  $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
124  $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
125  $sql .= ")";
126 
127  $resql = $db->query($sql);
128  if (!$resql) dol_print_error($db);
129 }
130 
131 // Disable a document generator module
132 if ($action == 'del')
133 {
134  $type = 'company';
135  $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
136  $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".$conf->entity;
137  $resql = $db->query($sql);
138  if (!$resql) dol_print_error($db);
139 }
140 
141 // Define default generator
142 if ($action == 'setdoc')
143 {
144  $label = GETPOST('label', 'alpha');
145  $scandir = GETPOST('scan_dir', 'alpha');
146 
147  $db->begin();
148 
149  dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
150 
151  // On active le modele
152  $type = 'company';
153  $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
154  $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'";
155  $sql_del .= " AND type = '".$db->escape($type)."'";
156  $sql_del .= " AND entity = ".$conf->entity;
157  dol_syslog("societe.php ".$sql);
158  $result1 = $db->query($sql_del);
159 
160  $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
161  $sql .= " VALUES ('".$db->escape($value)."', '".$db->escape($type)."', ".$conf->entity.", ";
162  $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
163  $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
164  $sql .= ")";
165  dol_syslog("societe.php", LOG_DEBUG);
166  $result2 = $db->query($sql);
167  if ($result1 && $result2)
168  {
169  $db->commit();
170  } else {
171  $db->rollback();
172  }
173 }
174 
175 //Activate Set ref in list
176 if ($action == "setaddrefinlist") {
177  $setaddrefinlist = GETPOST('value', 'int');
178  $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
179  if (!($res > 0)) $error++;
180  if (!$error)
181  {
182  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
183  } else {
184  setEventMessages($langs->trans("Error"), null, 'errors');
185  }
186 }
187 
188 //Activate Set adress in list
189 if ($action == "setaddadressinlist") {
190  $val = GETPOST('value', 'int');
191  $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
192  if (!($res > 0)) $error++;
193  if (!$error)
194  {
195  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
196  } else {
197  setEventMessages($langs->trans("Error"), null, 'errors');
198  }
199 }
200 
201 //Activate Set email phone town in contact list
202 if ($action == "setaddemailphonetownincontactlist") {
203  $val = GETPOST('value', 'int');
204  $res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
205  if (!($res > 0)) $error++;
206  if (!$error) {
207  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
208  } else {
209  setEventMessages($langs->trans("Error"), null, 'errors');
210  }
211 }
212 
213 //Activate Ask For Preferred Shipping Method
214 if ($action == "setaskforshippingmet") {
215  $setaskforshippingmet = GETPOST('value', 'int');
216  $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
217  if (!($res > 0)) $error++;
218  if (!$error)
219  {
220  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
221  } else {
222  setEventMessages($langs->trans("Error"), null, 'errors');
223  }
224 }
225 
226 //Activate "Disable prospect/customer type"
227 if ($action == "setdisableprospectcustomer") {
228  $setdisableprospectcustomer = GETPOST('value', 'int');
229  $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
230  if (!($res > 0)) $error++;
231  if (!$error)
232  {
233  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
234  } else {
235  setEventMessages($langs->trans("Error"), null, 'errors');
236  }
237 }
238 
239 //Activate ProfId unique
240 if ($action == 'setprofid')
241 {
242  $status = GETPOST('status', 'alpha');
243 
244  $idprof = "SOCIETE_".$value."_UNIQUE";
245  if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
246  {
247  //header("Location: ".$_SERVER["PHP_SELF"]);
248  //exit;
249  } else {
250  dol_print_error($db);
251  }
252 }
253 
254 //Activate ProfId mandatory
255 if ($action == 'setprofidmandatory')
256 {
257  $status = GETPOST('status', 'alpha');
258 
259  $idprof = "SOCIETE_".$value."_MANDATORY";
260  if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
261  {
262  //header("Location: ".$_SERVER["PHP_SELF"]);
263  //exit;
264  } else {
265  dol_print_error($db);
266  }
267 }
268 
269 //Activate ProfId invoice mandatory
270 if ($action == 'setprofidinvoicemandatory')
271 {
272  $status = GETPOST('status', 'alpha');
273 
274  $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
275  if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
276  {
277  //header("Location: ".$_SERVER["PHP_SELF"]);
278  //exit;
279  } else {
280  dol_print_error($db);
281  }
282 }
283 
284 //Set hide closed customer into combox or select
285 if ($action == 'sethideinactivethirdparty')
286 {
287  $status = GETPOST('status', 'alpha');
288 
289  if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0)
290  {
291  header("Location: ".$_SERVER["PHP_SELF"]);
292  exit;
293  } else {
294  dol_print_error($db);
295  }
296 }
297 if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
298  $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
299  $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
300  if (!($res > 0)) $error++;
301  if (!$error)
302  {
303  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
304  } else {
305  setEventMessages($langs->trans("Error"), null, 'errors');
306  }
307 }
308 
309 /*
310  * View
311  */
312 
313 clearstatcache();
314 
315 $form = new Form($db);
316 
317 $help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
318 llxHeader('', $langs->trans("CompanySetup"), $help_url);
319 
320 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
321 print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
322 
323 
325 
326 print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
327 
328 $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
329 foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
330 
331 // Module to manage customer/supplier code
332 
333 print load_fiche_titre($langs->trans("CompanyCodeChecker"), '', '');
334 
335 print '<div class="div-table-responsive-no-min">';
336 print '<table class="noborder centpercent">'."\n";
337 print '<tr class="liste_titre">'."\n";
338 print ' <td>'.$langs->trans("Name").'</td>';
339 print ' <td>'.$langs->trans("Description").'</td>';
340 print ' <td>'.$langs->trans("Example").'</td>';
341 print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
342 print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
343 print "</tr>\n";
344 
345 $arrayofmodules = array();
346 
347 foreach ($dirsociete as $dirroot)
348 {
349  $dir = dol_buildpath($dirroot, 0);
350 
351  $handle = @opendir($dir);
352  if (is_resource($handle))
353  {
354  // Loop on each module find in opened directory
355  while (($file = readdir($handle)) !== false)
356  {
357  if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
358  {
359  $file = substr($file, 0, dol_strlen($file) - 4);
360 
361  try {
362  dol_include_once($dirroot.$file.'.php');
363  } catch (Exception $e)
364  {
365  dol_syslog($e->getMessage(), LOG_ERR);
366  }
367 
368  $modCodeTiers = new $file;
369 
370  // Show modules according to features level
371  if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
372  if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
373 
374  $arrayofmodules[$file] = $modCodeTiers;
375  }
376  }
377  closedir($handle);
378  }
379 }
380 
381 $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
382 
383 foreach ($arrayofmodules as $file => $modCodeTiers)
384 {
385  print '<tr class="oddeven">'."\n";
386  print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
387  print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
388  print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
389 
390  if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
391  {
392  print '<td class="center">'."\n";
393  print img_picto($langs->trans("Activated"), 'switch_on');
394  print "</td>\n";
395  } else {
396  $disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
397  print '<td class="center">';
398  if (!$disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
399  print img_picto($langs->trans("Disabled"), 'switch_off');
400  if (!$disabled) print '</a>';
401  print '</td>';
402  }
403 
404  print '<td class="center">';
405  $s = $modCodeTiers->getToolTip($langs, null, -1);
406  print $form->textwithpicto('', $s, 1);
407  print '</td>';
408 
409  print '</tr>';
410 }
411 print '</table>';
412 print '</div>';
413 
414 print "<br>";
415 
416 
417 // Select accountancy code numbering module
418 
419 print load_fiche_titre($langs->trans("AccountCodeManager"), '', '');
420 
421 print '<div class="div-table-responsive-no-min">';
422 print '<table class="noborder centpercent">';
423 print '<tr class="liste_titre">';
424 print '<td width="140">'.$langs->trans("Name").'</td>';
425 print '<td>'.$langs->trans("Description").'</td>';
426 print '<td>'.$langs->trans("Example").'</td>';
427 print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
428 print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
429 print "</tr>\n";
430 
431 $arrayofmodules = array();
432 
433 foreach ($dirsociete as $dirroot)
434 {
435  $dir = dol_buildpath($dirroot, 0);
436 
437  $handle = @opendir($dir);
438  if (is_resource($handle))
439  {
440  while (($file = readdir($handle)) !== false)
441  {
442  if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
443  {
444  $file = substr($file, 0, dol_strlen($file) - 4);
445 
446  try {
447  dol_include_once($dirroot.$file.'.php');
448  } catch (Exception $e)
449  {
450  dol_syslog($e->getMessage(), LOG_ERR);
451  }
452 
453  $modCodeCompta = new $file;
454 
455  $arrayofmodules[$file] = $modCodeCompta;
456  }
457  }
458  closedir($handle);
459  }
460 }
461 
462 $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
463 
464 
465 foreach ($arrayofmodules as $file => $modCodeCompta)
466 {
467  print '<tr class="oddeven">';
468  print '<td>'.$modCodeCompta->name."</td><td>\n";
469  print $modCodeCompta->info($langs);
470  print '</td>';
471  print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
472 
473  if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
474  {
475  print '<td class="center">';
476  print img_picto($langs->trans("Activated"), 'switch_on');
477  print '</td>';
478  } else {
479  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
480  print img_picto($langs->trans("Disabled"), 'switch_off');
481  print '</a></td>';
482  }
483  print '<td class="center">';
484  $s = $modCodeCompta->getToolTip($langs, null, -1);
485  print $form->textwithpicto('', $s, 1);
486  print '</td>';
487  print "</tr>\n";
488 }
489 print "</table>\n";
490 print '</div>';
491 
492 
493 /*
494  * Document templates generators
495  */
496 print '<br>';
497 print load_fiche_titre($langs->trans("ModelModules"), '', '');
498 
499 // Load array def with activated templates
500 $def = array();
501 $sql = "SELECT nom";
502 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
503 $sql .= " WHERE type = 'company'";
504 $sql .= " AND entity = ".$conf->entity;
505 $resql = $db->query($sql);
506 if ($resql)
507 {
508  $i = 0;
509  $num_rows = $db->num_rows($resql);
510  while ($i < $num_rows)
511  {
512  $array = $db->fetch_array($resql);
513  array_push($def, $array[0]);
514  $i++;
515  }
516 } else {
517  dol_print_error($db);
518 }
519 
520 print '<div class="div-table-responsive-no-min">';
521 print '<table class="noborder centpercent">';
522 print '<tr class="liste_titre">';
523 print '<td width="140">'.$langs->trans("Name").'</td>';
524 print '<td>'.$langs->trans("Description").'</td>';
525 print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
526 print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
527 print '<td class="center" width="60">'.$langs->trans("Preview").'</td>';
528 print "</tr>\n";
529 
530 foreach ($dirsociete as $dirroot)
531 {
532  $dir = dol_buildpath($dirroot.'doc/', 0);
533 
534  $handle = @opendir($dir);
535  if (is_resource($handle))
536  {
537  while (($file = readdir($handle)) !== false)
538  {
539  if (preg_match('/\.modules\.php$/i', $file))
540  {
541  $name = substr($file, 4, dol_strlen($file) - 16);
542  $classname = substr($file, 0, dol_strlen($file) - 12);
543 
544  try {
545  dol_include_once($dirroot.'doc/'.$file);
546  } catch (Exception $e)
547  {
548  dol_syslog($e->getMessage(), LOG_ERR);
549  }
550 
551  $module = new $classname($db);
552 
553  $modulequalified = 1;
554  if (!empty($module->version)) {
555  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
556  elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
557  }
558 
559  if ($modulequalified)
560  {
561  print '<tr class="oddeven"><td width="100">';
562  print $module->name;
563  print "</td><td>\n";
564  if (method_exists($module, 'info')) print $module->info($langs);
565  else print $module->description;
566  print '</td>';
567 
568  // Activate / Disable
569  if (in_array($name, $def))
570  {
571  print "<td class=\"center\">\n";
572  //if ($conf->global->COMPANY_ADDON_PDF != "$name")
573  //{
574  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
575  print img_picto($langs->trans("Enabled"), 'switch_on');
576  print '</a>';
577  //}
578  //else
579  //{
580  // print img_picto($langs->trans("Enabled"),'on');
581  //}
582  print "</td>";
583  } else {
584  if (versioncompare($module->phpmin, versionphparray()) > 0)
585  {
586  print '<td class="center">'."\n";
587  print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off');
588  print "</td>";
589  } else {
590  print '<td class="center">'."\n";
591  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
592  print "</td>";
593  }
594  }
595 
596  // Info
597  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
598  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
599  if ($module->type == 'pdf')
600  {
601  $htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
602  }
603  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
604  $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1);
605 
606  print '<td class="center nowrap">';
607  print $form->textwithpicto('', $htmltooltip, 1, 0);
608  print '</td>';
609 
610  // Preview
611  print '<td class="center nowrap">';
612  if ($module->type == 'pdf')
613  {
614  $linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
615  } else {
616  $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
617  }
618  print $linkspec;
619  print '</td>';
620 
621  print "</tr>\n";
622  }
623  }
624  }
625  closedir($handle);
626  }
627 }
628 print '</table>';
629 print '</div>';
630 
631 print '<br>';
632 
633 //IDProf
634 print load_fiche_titre($langs->trans("CompanyIdProfChecker"), '', '');
635 
636 print '<div class="div-table-responsive-no-min">';
637 print '<table class="noborder centpercent">';
638 print '<tr class="liste_titre">';
639 print '<td>'.$langs->trans("Name").'</td>';
640 print '<td>'.$langs->trans("Description").'</td>';
641 print '<td class="center">'.$langs->trans("MustBeUnique").'</td>';
642 print '<td class="center">'.$langs->trans("MustBeMandatory").'</td>';
643 print '<td class="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>';
644 print "</tr>\n";
645 
646 $profid['IDPROF1'][0] = $langs->trans("ProfId1");
647 $profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code);
648 $profid['IDPROF2'][0] = $langs->trans("ProfId2");
649 $profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code);
650 $profid['IDPROF3'][0] = $langs->trans("ProfId3");
651 $profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code);
652 $profid['IDPROF4'][0] = $langs->trans("ProfId4");
653 $profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code);
654 $profid['IDPROF5'][0] = $langs->trans("ProfId5");
655 $profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code);
656 $profid['IDPROF6'][0] = $langs->trans("ProfId6");
657 $profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
658 $profid['EMAIL'][0] = $langs->trans("EMail");
659 $profid['EMAIL'][1] = $langs->trans('Email');
660 
661 $nbofloop = count($profid);
662 foreach ($profid as $key => $val)
663 {
664  if ($profid[$key][1] != '-')
665  {
666  print '<tr class="oddeven">';
667  print '<td>'.$profid[$key][0]."</td><td>\n";
668  print $profid[$key][1];
669  print '</td>';
670 
671  $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE';
672  $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
673  $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
674 
675  $verif = (empty($conf->global->$idprof_unique) ?false:true);
676  $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true);
677  $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true);
678 
679  if ($verif)
680  {
681  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
682  print img_picto($langs->trans("Activated"), 'switch_on');
683  print '</a></td>';
684  } else {
685  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=1">';
686  print img_picto($langs->trans("Disabled"), 'switch_off');
687  print '</a></td>';
688  }
689 
690  if ($mandatory)
691  {
692  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
693  print img_picto($langs->trans("Activated"), 'switch_on');
694  print '</a></td>';
695  } else {
696  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandator&token='.newToken().'&value='.$key.'&status=1">';
697  print img_picto($langs->trans("Disabled"), 'switch_off');
698  print '</a></td>';
699  }
700 
701  if ($invoice_mandatory)
702  {
703  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
704  print img_picto($langs->trans("Activated"), 'switch_on');
705  print '</a></td>';
706  } else {
707  print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
708  print img_picto($langs->trans("Disabled"), 'switch_off');
709  print '</a></td>';
710  }
711 
712  print "</tr>\n";
713  }
714  $i++;
715 }
716 
717 print "</table>\n";
718 print '</div>';
719 
720 print "<br>\n";
721 
722 print load_fiche_titre($langs->trans("Other"), '', '');
723 
724 // Autres options
725 $form = new Form($db);
726 
727 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
728 print '<input type="hidden" name="token" value="'.newToken().'">';
729 print '<input type="hidden" name="action" value="updateoptions">';
730 
731 print '<div class="div-table-responsive-no-min">';
732 print '<table class="noborder centpercent">';
733 print '<tr class="liste_titre">';
734 print "<td>".$langs->trans("Parameters")."</td>\n";
735 print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
736 print '<td width="80">&nbsp;</td></tr>'."\n";
737 
738 // Utilisation formulaire Ajax sur choix societe
739 
740 print '<tr class="oddeven">';
741 print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
742 if (!$conf->use_javascript_ajax)
743 {
744  print '<td class="nowrap right" colspan="2">';
745  print $langs->trans("NotAvailableWhenAjaxDisabled");
746  print "</td>";
747 } else {
748  print '<td width="60" class="right">';
749  $arrval = array('0'=>$langs->trans("No"),
750  '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
751  '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
752  '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
753  );
754  print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
755  print '</td><td class="right">';
756  print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
757  print "</td>";
758 }
759 print '</tr>';
760 
761 
762 print '<tr class="oddeven">';
763 print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
764 if (!$conf->use_javascript_ajax)
765 {
766  print '<td class="nowrap right" colspan="2">';
767  print $langs->trans("NotAvailableWhenAjaxDisabled");
768  print "</td>";
769 } else {
770  print '<td width="60" class="right">';
771  $arrval = array('0'=>$langs->trans("No"),
772  '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
773  '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
774  '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
775  );
776  print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
777  print '</td><td class="right">';
778  print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
779  print "</td>";
780 }
781 print '</tr>';
782 
783 
784 
785 print '<tr class="oddeven">';
786 print '<td width="80%">'.$langs->trans("AddRefInList").'</td>';
787 print '<td>&nbsp</td>';
788 print '<td class="center">';
789 if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST))
790 {
791  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
792  print img_picto($langs->trans("Activated"), 'switch_on');
793 } else {
794  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=1">';
795  print img_picto($langs->trans("Disabled"), 'switch_off');
796 }
797 print '</a></td>';
798 print '</tr>';
799 
800 print '<tr class="oddeven">';
801 print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>';
802 print '<td>&nbsp</td>';
803 print '<td class="center">';
804 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST))
805 {
806  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
807  print img_picto($langs->trans("Activated"), 'switch_on');
808 } else {
809  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=1">';
810  print img_picto($langs->trans("Disabled"), 'switch_off');
811 }
812 print '</a></td>';
813 print '</tr>';
814 
815 print '<tr class="oddeven">';
816 print '<td width="80%">'.$langs->trans("AddEmailPhoneTownInContactList").'</td>';
817 print '<td>&nbsp</td>';
818 print '<td class="center">';
819 if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
820  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=0">';
821  print img_picto($langs->trans("Activated"), 'switch_on');
822 } else {
823  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=1">';
824  print img_picto($langs->trans("Disabled"), 'switch_off');
825 }
826 print '</a></td>';
827 print '</tr>';
828 
829 if (!empty($conf->expedition->enabled)) {
830  if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal)
831  print '<tr class="oddeven">';
832  print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
833  print '<td>&nbsp</td>';
834  print '<td class="center">';
835  if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD))
836  {
837  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
838  print img_picto($langs->trans("Activated"), 'switch_on');
839  } else {
840  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=1">';
841  print img_picto($langs->trans("Disabled"), 'switch_off');
842  }
843  print '</a></td>';
844  print '</tr>';
845  }
846 }
847 
848 // Disable Prospect/Customer thirdparty type
849 print '<tr class="oddeven">';
850 print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
851 print '<td>&nbsp</td>';
852 print '<td class="center">';
853 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS))
854 {
855  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
856  print img_picto($langs->trans("Activated"), 'switch_on');
857 } else {
858  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=1">';
859  print img_picto($langs->trans("Disabled"), 'switch_off');
860 }
861 print '</a></td>';
862 print '</tr>';
863 
864 // Default Prospect/Customer thirdparty type on customer création
865 print '<tr class="oddeven">';
866 print '<td width="80%">'.$langs->trans("DefaultCustomerType").'</td>';
867 print '<td>';
868 print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin');
869 print '</td>';
870 print '<td class="center">';
871 print '<input type="submit" class="button" name="THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT" value="'.$langs->trans("Modify").'">';
872 print '</td>';
873 print '</tr>';
874 
875 print '</table>';
876 print '</div>';
877 
878 print '</form>';
879 
880 
881 print dol_get_fiche_end();
882 
883 // End of page
884 llxFooter();
885 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:575
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
societe_admin_prepare_head()
Return array head with list of tabs to view object informations.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition: admin.lib.php:66
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
versionphparray()
Return version PHP.
Definition: admin.lib.php:125
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...