1<?php 2/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> 6 * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> 7 * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es> 8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <https://www.gnu.org/licenses/>. 22 */ 23 24/** 25 * \file htdocs/admin/facture.php 26 * \ingroup facture 27 * \brief Page to setup invoice module 28 */ 29 30require '../main.inc.php'; 31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; 34require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 35 36// Load translation files required by the page 37$langs->loadLangs(array('admin', 'errors', 'other', 'bills')); 38 39if (!$user->admin) { 40 accessforbidden(); 41} 42 43$action = GETPOST('action', 'aZ09'); 44$value = GETPOST('value', 'alpha'); 45$label = GETPOST('label', 'alpha'); 46$scandir = GETPOST('scan_dir', 'alpha'); 47$type = 'invoice'; 48 49 50/* 51 * Actions 52 */ 53 54include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; 55 56if ($action == 'updateMask') { 57 $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); 58 $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); 59 $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); 60 $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); 61 $maskinvoice = GETPOST('maskinvoice', 'alpha'); 62 $maskreplacement = GETPOST('maskreplacement', 'alpha'); 63 $maskcredit = GETPOST('maskcredit', 'alpha'); 64 $maskdeposit = GETPOST('maskdeposit', 'alpha'); 65 if ($maskconstinvoice) { 66 $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); 67 } 68 if ($maskconstreplacement) { 69 $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); 70 } 71 if ($maskconstcredit) { 72 $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); 73 } 74 if ($maskconstdeposit) { 75 $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); 76 } 77 78 if (!($res > 0)) { 79 $error++; 80 } 81 82 if (!$error) { 83 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 84 } else { 85 setEventMessages($langs->trans("Error"), null, 'errors'); 86 } 87} elseif ($action == 'specimen') { 88 $modele = GETPOST('module', 'alpha'); 89 90 $facture = new Facture($db); 91 $facture->initAsSpecimen(); 92 93 // Search template files 94 $file = ''; $classname = ''; $filefound = 0; 95 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); 96 foreach ($dirmodels as $reldir) { 97 $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); 98 if (file_exists($file)) { 99 $filefound = 1; 100 $classname = "pdf_".$modele; 101 break; 102 } 103 } 104 105 if ($filefound) { 106 require_once $file; 107 108 $module = new $classname($db); 109 110 if ($module->write_file($facture, $langs) > 0) { 111 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); 112 return; 113 } else { 114 setEventMessages($module->error, $module->errors, 'errors'); 115 dol_syslog($module->error, LOG_ERR); 116 } 117 } else { 118 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); 119 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); 120 } 121} elseif ($action == 'set') { 122 // Activate a model 123 $ret = addDocumentModel($value, $type, $label, $scandir); 124} elseif ($action == 'del') { 125 $ret = delDocumentModel($value, $type); 126 if ($ret > 0) { 127 if ($conf->global->FACTURE_ADDON_PDF == "$value") { 128 dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); 129 } 130 } 131} elseif ($action == 'setdoc') { 132 // Set default model 133 if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { 134 // La constante qui a ete lue en avant du nouveau set 135 // on passe donc par une variable pour avoir un affichage coherent 136 $conf->global->FACTURE_ADDON_PDF = $value; 137 } 138 139 // On active le modele 140 $ret = delDocumentModel($value, $type); 141 if ($ret > 0) { 142 $ret = addDocumentModel($value, $type, $label, $scandir); 143 } 144} elseif ($action == 'setmod') { 145 // TODO Verifier si module numerotation choisi peut etre active 146 // par appel methode canBeActivated 147 148 dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); 149} elseif ($action == 'setribchq') { 150 $rib = GETPOST('rib', 'alpha'); 151 $chq = GETPOST('chq', 'alpha'); 152 153 $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); 154 $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); 155 156 if (!($res > 0)) { 157 $error++; 158 } 159 160 if (!$error) { 161 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 162 } else { 163 setEventMessages($langs->trans("Error"), null, 'errors'); 164 } 165} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { 166 $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); 167 168 $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); 169 170 if (!($res > 0)) { 171 $error++; 172 } 173 174 if (!$error) { 175 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 176 } else { 177 setEventMessages($langs->trans("Error"), null, 'errors'); 178 } 179} elseif ($action == 'set_INVOICE_FREE_TEXT') { 180 $freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string 181 182 $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); 183 184 if (!($res > 0)) { 185 $error++; 186 } 187 188 if (!$error) { 189 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 190 } else { 191 setEventMessages($langs->trans("Error"), null, 'errors'); 192 } 193} elseif ($action == 'setforcedate') { 194 $forcedate = GETPOST('forcedate', 'alpha'); 195 196 $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); 197 198 if (!($res > 0)) { 199 $error++; 200 } 201 202 if (!$error) { 203 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 204 } else { 205 setEventMessages($langs->trans("Error"), null, 'errors'); 206 } 207} elseif ($action == 'setDefaultPDFModulesByType') { 208 $invoicetypemodels = GETPOST('invoicetypemodels'); 209 210 if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) { 211 $error = 0; 212 213 foreach ($invoicetypemodels as $type => $value) { 214 $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); 215 if (!($res > 0)) { 216 $error++; 217 } 218 } 219 220 if (!$error) { 221 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 222 } else { 223 setEventMessages($langs->trans("Error"), null, 'errors'); 224 } 225 } 226} 227 228 229/* 230 * View 231 */ 232 233$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); 234 235llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'); 236 237$form = new Form($db); 238 239 240$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; 241print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); 242 243$head = invoice_admin_prepare_head(); 244print dol_get_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'invoice'); 245 246/* 247 * Numbering module 248 */ 249 250print load_fiche_titre($langs->trans("BillsNumberingModule"), '', ''); 251 252print '<div class="div-table-responsive-no-min">'; 253print '<table class="noborder centpercent">'; 254print '<tr class="liste_titre">'; 255print '<td>'.$langs->trans("Name").'</td>'; 256print '<td>'.$langs->trans("Description").'</td>'; 257print '<td class="nowrap">'.$langs->trans("Example").'</td>'; 258print '<td class="center" width="60">'.$langs->trans("Status").'</td>'; 259print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>'; 260print '</tr>'."\n"; 261 262clearstatcache(); 263 264foreach ($dirmodels as $reldir) { 265 $dir = dol_buildpath($reldir."core/modules/facture/"); 266 if (is_dir($dir)) { 267 $handle = opendir($dir); 268 if (is_resource($handle)) { 269 while (($file = readdir($handle)) !== false) { 270 if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { 271 $filebis = $file; 272 $classname = preg_replace('/\.php$/', '', $file); 273 // For compatibility 274 if (!is_file($dir.$filebis)) { 275 $filebis = $file."/".$file.".modules.php"; 276 $classname = "mod_facture_".$file; 277 } 278 // Check if there is a filter on country 279 preg_match('/\-(.*)_(.*)$/', $classname, $reg); 280 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) { 281 continue; 282 } 283 284 $classname = preg_replace('/\-.*$/', '', $classname); 285 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') { 286 // Charging the numbering class 287 require_once $dir.$filebis; 288 289 $module = new $classname($db); 290 291 // Show modules according to features level 292 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { 293 continue; 294 } 295 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { 296 continue; 297 } 298 299 if ($module->isEnabled()) { 300 print '<tr class="oddeven"><td width="100">'; 301 echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); 302 print "</td><td>\n"; 303 304 print $module->info(); 305 306 print '</td>'; 307 308 // Show example of numbering module 309 print '<td class="nowrap">'; 310 $tmp = $module->getExample(); 311 if (preg_match('/^Error/', $tmp)) { 312 $langs->load("errors"); 313 print '<div class="error">'.$langs->trans($tmp).'</div>'; 314 } elseif ($tmp == 'NotConfigured') { 315 print $langs->trans($tmp); 316 } else { 317 print $tmp; 318 } 319 print '</td>'."\n"; 320 321 print '<td class="center">'; 322 //print "> ".$conf->global->FACTURE_ADDON." - ".$file; 323 if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) { 324 print img_picto($langs->trans("Activated"), 'switch_on'); 325 } else { 326 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; 327 } 328 print '</td>'; 329 330 $facture = new Facture($db); 331 $facture->initAsSpecimen(); 332 333 // Example for standard invoice 334 $htmltooltip = ''; 335 $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; 336 $facture->type = 0; 337 $nextval = $module->getNextValue($mysoc, $facture); 338 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval 339 $htmltooltip .= $langs->trans("NextValueForInvoices").': '; 340 if ($nextval) { 341 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { 342 $nextval = $langs->trans($nextval); 343 } 344 $htmltooltip .= $nextval.'<br>'; 345 } else { 346 $htmltooltip .= $langs->trans($module->error).'<br>'; 347 } 348 } 349 // Example for remplacement 350 $facture->type = 1; 351 $nextval = $module->getNextValue($mysoc, $facture); 352 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval 353 $htmltooltip .= $langs->trans("NextValueForReplacements").': '; 354 if ($nextval) { 355 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { 356 $nextval = $langs->trans($nextval); 357 } 358 $htmltooltip .= $nextval.'<br>'; 359 } else { 360 $htmltooltip .= $langs->trans($module->error).'<br>'; 361 } 362 } 363 364 // Example for credit invoice 365 $facture->type = 2; 366 $nextval = $module->getNextValue($mysoc, $facture); 367 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval 368 $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; 369 if ($nextval) { 370 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { 371 $nextval = $langs->trans($nextval); 372 } 373 $htmltooltip .= $nextval.'<br>'; 374 } else { 375 $htmltooltip .= $langs->trans($module->error).'<br>'; 376 } 377 } 378 // Example for deposit invoice 379 $facture->type = 3; 380 $nextval = $module->getNextValue($mysoc, $facture); 381 if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval 382 $htmltooltip .= $langs->trans("NextValueForDeposit").': '; 383 if ($nextval) { 384 if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { 385 $nextval = $langs->trans($nextval); 386 } 387 $htmltooltip .= $nextval; 388 } else { 389 $htmltooltip .= $langs->trans($module->error); 390 } 391 } 392 393 print '<td class="center">'; 394 print $form->textwithpicto('', $htmltooltip, 1, 0); 395 396 if ($conf->global->FACTURE_ADDON.'.php' == $file) { // If module is the one used, we show existing errors 397 if (!empty($module->error)) { 398 dol_htmloutput_mesg($module->error, '', 'error', 1); 399 } 400 } 401 402 print '</td>'; 403 404 print "</tr>\n"; 405 } 406 } 407 } 408 } 409 closedir($handle); 410 } 411 } 412} 413 414print '</table>'; 415print '</div>'; 416 417 418/* 419 * Document templates generators 420 */ 421print '<br>'; 422print load_fiche_titre($langs->trans("BillsPDFModules"), '', ''); 423 424// Load array def with activated templates 425$type = 'invoice'; 426$def = array(); 427$sql = "SELECT nom"; 428$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; 429$sql .= " WHERE type = '".$db->escape($type)."'"; 430$sql .= " AND entity = ".$conf->entity; 431$resql = $db->query($sql); 432if ($resql) { 433 $i = 0; 434 $num_rows = $db->num_rows($resql); 435 while ($i < $num_rows) { 436 $array = $db->fetch_array($resql); 437 array_push($def, $array[0]); 438 $i++; 439 } 440} else { 441 dol_print_error($db); 442} 443 444print '<div class="div-table-responsive-no-min">'; 445print '<table class="noborder centpercent">'; 446print '<tr class="liste_titre">'; 447print '<td>'.$langs->trans("Name").'</td>'; 448print '<td>'.$langs->trans("Description").'</td>'; 449print '<td class="center" width="60">'.$langs->trans("Status").'</td>'; 450print '<td class="center" width="60">'.$langs->trans("Default").'</td>'; 451print '<td class="center" width="32">'.$langs->trans("ShortInfo").'</td>'; 452print '<td class="center" width="32">'.$langs->trans("Preview").'</td>'; 453print "</tr>\n"; 454 455clearstatcache(); 456 457$activatedModels = array(); 458 459foreach ($dirmodels as $reldir) { 460 foreach (array('', '/doc') as $valdir) { 461 $realpath = $reldir."core/modules/facture".$valdir; 462 $dir = dol_buildpath($realpath); 463 464 if (is_dir($dir)) { 465 $handle = opendir($dir); 466 if (is_resource($handle)) { 467 while (($file = readdir($handle)) !== false) { 468 $filelist[] = $file; 469 } 470 closedir($handle); 471 arsort($filelist); 472 473 foreach ($filelist as $file) { 474 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { 475 if (file_exists($dir.'/'.$file)) { 476 $name = substr($file, 4, dol_strlen($file) - 16); 477 $classname = substr($file, 0, dol_strlen($file) - 12); 478 479 require_once $dir.'/'.$file; 480 $module = new $classname($db); 481 482 $modulequalified = 1; 483 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { 484 $modulequalified = 0; 485 } 486 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { 487 $modulequalified = 0; 488 } 489 490 if ($modulequalified) { 491 print '<tr class="oddeven"><td width="100">'; 492 print (empty($module->name) ? $name : $module->name); 493 print "</td><td>\n"; 494 if (method_exists($module, 'info')) { 495 print $module->info($langs); 496 } else { 497 print $module->description; 498 } 499 print '</td>'; 500 501 // Active 502 if (in_array($name, $def)) { 503 print '<td class="center">'."\n"; 504 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'">'; 505 print img_picto($langs->trans("Enabled"), 'switch_on'); 506 print '</a>'; 507 print '</td>'; 508 } else { 509 print '<td class="center">'."\n"; 510 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>'; 511 print "</td>"; 512 } 513 514 // Defaut 515 print '<td class="center">'; 516 if ($conf->global->FACTURE_ADDON_PDF == "$name") { 517 print img_picto($langs->trans("Default"), 'on'); 518 } else { 519 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>'; 520 } 521 print '</td>'; 522 523 // Info 524 $htmltooltip = ''.$langs->trans("Name").': '.$module->name; 525 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); 526 if ($module->type == 'pdf') { 527 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; 528 } 529 $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; 530 531 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; 532 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); 533 $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); 534 $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); 535 $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1); 536 $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1); 537 $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); 538 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1); 539 540 541 print '<td class="center">'; 542 print $form->textwithpicto('', $htmltooltip, 1, 0); 543 print '</td>'; 544 545 // Preview 546 print '<td class="center">'; 547 if ($module->type == 'pdf') { 548 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; 549 } else { 550 print img_object($langs->trans("PreviewNotAvailable"), 'generic'); 551 } 552 print '</td>'; 553 554 print "</tr>\n"; 555 } 556 } 557 } 558 } 559 } 560 } 561 } 562} 563print '</table>'; 564print '</div>'; 565 566if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf 567 /* 568 * Document templates generators 569 */ 570 print '<br>'; 571 print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); 572 573 print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">'; 574 print '<input type="hidden" name="token" value="'.newToken().'" />'; 575 print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >'; 576 577 print '<div class="div-table-responsive-no-min">'; 578 print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">'; 579 print '<tr class="liste_titre">'; 580 print '<td>'.$langs->trans("Type").'</td>'; 581 print '<td>'.$langs->trans("Name").'</td>'; 582 print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; 583 print "</tr>\n"; 584 585 $listtype = array( 586 Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), 587 Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), 588 Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), 589 Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), 590 ); 591 if (!empty($conf->global->INVOICE_USE_SITUATION)) { 592 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); 593 } 594 595 foreach ($listtype as $type => $trans) { 596 $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; 597 $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; 598 print '<tr >'; 599 print '<td>'.$trans.'</td>'; 600 print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>'; 601 print "</tr>\n"; 602 } 603 604 print '</table>'; 605 print '</div>'; 606 607 print "</form>"; 608} 609 610/* 611 * Payment modes 612 */ 613print '<br>'; 614print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"), '', ''); 615 616print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 617print '<input type="hidden" name="token" value="'.newToken().'" />'; 618 619print '<div class="div-table-responsive-no-min">'; 620print '<table class="noborder centpercent">'; 621 622print '<tr class="liste_titre">'; 623print '<td>'; 624print '<input type="hidden" name="action" value="setribchq">'; 625print $langs->trans("PaymentMode").'</td>'; 626print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; 627print "</tr>\n"; 628 629print '<tr class="oddeven">'; 630print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>"; 631print "<td>"; 632if (!empty($conf->banque->enabled)) { 633 $sql = "SELECT rowid, label"; 634 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; 635 $sql .= " WHERE clos = 0"; 636 $sql .= " AND courant = 1"; 637 $sql .= " AND entity IN (".getEntity('bank_account').")"; 638 $resql = $db->query($sql); 639 if ($resql) { 640 $num = $db->num_rows($resql); 641 $i = 0; 642 if ($num > 0) { 643 print '<select name="rib" class="flat" id="rib">'; 644 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; 645 while ($i < $num) { 646 $row = $db->fetch_row($resql); 647 648 print '<option value="'.$row[0].'"'; 649 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : ''; 650 print '>'.$row[1].'</option>'; 651 652 $i++; 653 } 654 print "</select>"; 655 } else { 656 print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>'; 657 } 658 } 659} else { 660 print $langs->trans("BankModuleNotActive"); 661} 662print "</td></tr>"; 663 664print '<tr class="oddeven">'; 665print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>"; 666print "<td>"; 667print '<select class="flat" name="chq" id="chq">'; 668print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; 669print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>'; 670 671$sql = "SELECT rowid, label"; 672$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; 673$sql .= " WHERE clos = 0"; 674$sql .= " AND courant = 1"; 675$sql .= " AND entity IN (".getEntity('bank_account').")"; 676 677$resql = $db->query($sql); 678if ($resql) { 679 $num = $db->num_rows($resql); 680 $i = 0; 681 while ($i < $num) { 682 $row = $db->fetch_row($resql); 683 684 print '<option value="'.$row[0].'"'; 685 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : ''; 686 print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>'; 687 688 $i++; 689 } 690} 691print "</select>"; 692print "</td></tr>"; 693print "</table>"; 694print '</div>'; 695 696print "</form>"; 697 698 699print "<br>"; 700print load_fiche_titre($langs->trans("OtherOptions"), '', ''); 701 702print '<div class="div-table-responsive-no-min">'; 703print '<table class="noborder centpercent">'; 704print '<tr class="liste_titre">'; 705print '<td>'.$langs->trans("Parameter").'</td>'; 706print '<td class="center" width="60">'.$langs->trans("Value").'</td>'; 707print '<td width="80"> </td>'; 708print "</tr>\n"; 709 710// Force date validation 711print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 712print '<input type="hidden" name="token" value="'.newToken().'" />'; 713print '<input type="hidden" name="action" value="setforcedate" />'; 714print '<tr class="oddeven"><td>'; 715print $langs->trans("ForceInvoiceDate"); 716print '</td><td width="60" class="center">'; 717print $form->selectyesno("forcedate", $conf->global->FAC_FORCE_DATE_VALIDATION, 1); 718print '</td><td class="right">'; 719print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />'; 720print "</td></tr>\n"; 721print '</form>'; 722 723$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); 724$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); 725$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; 726foreach ($substitutionarray as $key => $val) { 727 $htmltext .= $key.'<br>'; 728} 729$htmltext .= '</i>'; 730 731print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 732print '<input type="hidden" name="token" value="'.newToken().'" />'; 733print '<input type="hidden" name="action" value="set_INVOICE_FREE_TEXT" />'; 734print '<tr class="oddeven"><td colspan="2">'; 735print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; 736$variablename = 'INVOICE_FREE_TEXT'; 737if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { 738 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; 739} else { 740 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 741 $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); 742 print $doleditor->Create(); 743} 744print '</td><td class="right">'; 745print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />'; 746print "</td></tr>\n"; 747print '</form>'; 748 749 750print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 751print '<input type="hidden" name="token" value="'.newToken().'" />'; 752print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />'; 753print '<tr class="oddeven"><td>'; 754print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>'; 755print '</td>'; 756print '<td><input class="flat minwidth200imp" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.$conf->global->FACTURE_DRAFT_WATERMARK.'" />'; 757print '</td><td class="right">'; 758print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />'; 759print "</td></tr>\n"; 760print '</form>'; 761 762print '</table>'; 763print '</div>'; 764 765/* 766 * Repertoire 767 */ 768print '<br>'; 769print load_fiche_titre($langs->trans("PathToDocuments"), '', ''); 770 771print '<div class="div-table-responsive-no-min">'; 772print '<table class="noborder centpercent">'."\n"; 773print '<tr class="liste_titre">'."\n"; 774print '<td>'.$langs->trans("Name").'</td>'."\n"; 775print '<td>'.$langs->trans("Value").'</td>'."\n"; 776print "</tr>\n"; 777print '<tr class="oddeven">'."\n"; 778print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n"; 779print '<td>'.$conf->facture->dir_output.'</td>'."\n"; 780print '</tr>'."\n"; 781print "</table>\n"; 782print "</div>\n"; 783 784/* 785 * Notifications 786 */ 787print '<br>'; 788print load_fiche_titre($langs->trans("Notifications"), '', ''); 789 790print '<div class="div-table-responsive-no-min">'; 791print '<table class="noborder centpercent">'; 792print '<tr class="liste_titre">'; 793print '<td>'.$langs->trans("Parameter").'</td>'; 794print '<td class="center" width="60"></td>'; 795print '<td width="80"> </td>'; 796print "</tr>\n"; 797print '<tr class="oddeven"><td colspan="2">'; 798print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>'; 799print '</td><td class="right">'; 800print "</td></tr>\n"; 801print '</table>'; 802print "</div>\n"; 803 804 805print dol_get_fiche_end(); 806 807// End of page 808llxFooter(); 809$db->close(); 810