propal.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  5. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  6. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  7. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  9. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/admin/propal.php
  26. * \ingroup propale
  27. * \brief Setup page for commercial proposal module
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("admin", "other", "errors", "propal"));
  36. if (!$user->admin) {
  37. accessforbidden();
  38. }
  39. $action = GETPOST('action', 'aZ09');
  40. $value = GETPOST('value', 'alpha');
  41. $label = GETPOST('label', 'alpha');
  42. $scandir = GETPOST('scan_dir', 'alpha');
  43. $type = 'propal';
  44. /*
  45. * Actions
  46. */
  47. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  48. $error = 0;
  49. if ($action == 'updateMask') {
  50. $maskconstpropal = GETPOST('maskconstpropal', 'alpha');
  51. $maskpropal = GETPOST('maskpropal', 'alpha');
  52. if ($maskconstpropal) {
  53. $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity);
  54. }
  55. if (!($res > 0)) {
  56. $error++;
  57. }
  58. if (!$error) {
  59. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  60. } else {
  61. setEventMessages($langs->trans("Error"), null, 'errors');
  62. }
  63. } elseif ($action == 'specimen') {
  64. $modele = GETPOST('module', 'alpha');
  65. $propal = new Propal($db);
  66. $propal->initAsSpecimen();
  67. // Search template files
  68. $file = ''; $classname = ''; $filefound = 0;
  69. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  70. foreach ($dirmodels as $reldir) {
  71. $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php");
  72. if (file_exists($file)) {
  73. $filefound = 1;
  74. $classname = "pdf_".$modele;
  75. break;
  76. }
  77. }
  78. if ($filefound) {
  79. require_once $file;
  80. $module = new $classname($db);
  81. if ($module->write_file($propal, $langs) > 0) {
  82. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
  83. return;
  84. } else {
  85. setEventMessages($module->error, $module->errors, 'errors');
  86. dol_syslog($module->error, LOG_ERR);
  87. }
  88. } else {
  89. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  90. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  91. }
  92. } elseif ($action == 'setribchq') {
  93. $rib = GETPOST('rib', 'alpha');
  94. $chq = GETPOST('chq', 'alpha');
  95. $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
  96. $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
  97. if (!($res > 0)) {
  98. $error++;
  99. }
  100. if (!$error) {
  101. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  102. } else {
  103. setEventMessages($langs->trans("Error"), null, 'errors');
  104. }
  105. } elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') {
  106. $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha');
  107. $res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
  108. if (!($res > 0)) {
  109. $error++;
  110. }
  111. if (!$error) {
  112. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  113. } else {
  114. setEventMessages($langs->trans("Error"), null, 'errors');
  115. }
  116. } elseif ($action == 'set_PROPOSAL_FREE_TEXT') {
  117. $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
  118. $res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
  119. if (!($res > 0)) {
  120. $error++;
  121. }
  122. if (!$error) {
  123. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  124. } else {
  125. setEventMessages($langs->trans("Error"), null, 'errors');
  126. }
  127. } elseif ($action == 'setdefaultduration') {
  128. $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity);
  129. if (!($res > 0)) {
  130. $error++;
  131. }
  132. if (!$error) {
  133. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  134. } else {
  135. setEventMessages($langs->trans("Error"), null, 'errors');
  136. }
  137. } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
  138. $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity);
  139. if (!($res > 0)) {
  140. $error++;
  141. }
  142. if (!$error) {
  143. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  144. } else {
  145. setEventMessages($langs->trans("Error"), null, 'errors');
  146. }
  147. } elseif ($action == 'set') {
  148. // Activate a model
  149. $ret = addDocumentModel($value, $type, $label, $scandir);
  150. } elseif ($action == 'del') {
  151. $ret = delDocumentModel($value, $type);
  152. if ($ret > 0) {
  153. if ($conf->global->PROPALE_ADDON_PDF == "$value") {
  154. dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity);
  155. }
  156. }
  157. } elseif ($action == 'setdoc') {
  158. if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  159. $conf->global->PROPALE_ADDON_PDF = $value;
  160. }
  161. // On active le modele
  162. $ret = delDocumentModel($value, $type);
  163. if ($ret > 0) {
  164. $ret = addDocumentModel($value, $type, $label, $scandir);
  165. }
  166. } elseif ($action == 'setmod') {
  167. // TODO Verifier si module numerotation choisi peut etre active
  168. // par appel methode canBeActivated
  169. dolibarr_set_const($db, "PROPALE_ADDON", $value, 'chaine', 0, '', $conf->entity);
  170. }
  171. /*
  172. * View
  173. */
  174. $form = new Form($db);
  175. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  176. llxHeader('', $langs->trans("PropalSetup"));
  177. //if ($mesg) print $mesg;
  178. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  179. print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup');
  180. $head = propal_admin_prepare_head();
  181. print dol_get_fiche_head($head, 'general', $langs->trans("Proposals"), -1, 'propal');
  182. /*
  183. * Module numerotation
  184. */
  185. print load_fiche_titre($langs->trans("ProposalsNumberingModules"), '', '');
  186. print '<table class="noborder centpercent">';
  187. print '<tr class="liste_titre">';
  188. print '<td>'.$langs->trans("Name")."</td>\n";
  189. print '<td>'.$langs->trans("Description")."</td>\n";
  190. print '<td class="nowrap">'.$langs->trans("Example")."</td>\n";
  191. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  192. print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  193. print '</tr>'."\n";
  194. clearstatcache();
  195. foreach ($dirmodels as $reldir) {
  196. $dir = dol_buildpath($reldir."core/modules/propale");
  197. if (is_dir($dir)) {
  198. $handle = opendir($dir);
  199. if (is_resource($handle)) {
  200. while (($file = readdir($handle)) !== false) {
  201. if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  202. $file = substr($file, 0, dol_strlen($file) - 4);
  203. require_once $dir.'/'.$file.'.php';
  204. $module = new $file;
  205. // Show modules according to features level
  206. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  207. continue;
  208. }
  209. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  210. continue;
  211. }
  212. if ($module->isEnabled()) {
  213. print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
  214. print $module->info();
  215. print '</td>';
  216. // Show example of numbering module
  217. print '<td class="nowrap">';
  218. $tmp = $module->getExample();
  219. if (preg_match('/^Error/', $tmp)) {
  220. $langs->load("errors");
  221. print '<div class="error">'.$langs->trans($tmp).'</div>';
  222. } elseif ($tmp == 'NotConfigured') {
  223. print $langs->trans($tmp);
  224. } else {
  225. print $tmp;
  226. }
  227. print '</td>'."\n";
  228. print '<td class="center">';
  229. if ($conf->global->PROPALE_ADDON == "$file") {
  230. print img_picto($langs->trans("Activated"), 'switch_on');
  231. } else {
  232. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
  233. print img_picto($langs->trans("Disabled"), 'switch_off');
  234. print '</a>';
  235. }
  236. print '</td>';
  237. $propal = new Propal($db);
  238. $propal->initAsSpecimen();
  239. // Info
  240. $htmltooltip = '';
  241. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  242. $propal->type = 0;
  243. $nextval = $module->getNextValue($mysoc, $propal);
  244. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  245. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  246. if ($nextval) {
  247. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  248. $nextval = $langs->trans($nextval);
  249. }
  250. $htmltooltip .= $nextval.'<br>';
  251. } else {
  252. $htmltooltip .= $langs->trans($module->error).'<br>';
  253. }
  254. }
  255. print '<td class="center">';
  256. print $form->textwithpicto('', $htmltooltip, 1, 0);
  257. print '</td>';
  258. print "</tr>\n";
  259. }
  260. }
  261. }
  262. closedir($handle);
  263. }
  264. }
  265. }
  266. print "</table><br>\n";
  267. /*
  268. * Document templates generators
  269. */
  270. print load_fiche_titre($langs->trans("ProposalsPDFModules"), '', '');
  271. // Load array def with activated templates
  272. $def = array();
  273. $sql = "SELECT nom";
  274. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  275. $sql .= " WHERE type = '".$db->escape($type)."'";
  276. $sql .= " AND entity = ".$conf->entity;
  277. $resql = $db->query($sql);
  278. if ($resql) {
  279. $i = 0;
  280. $num_rows = $db->num_rows($resql);
  281. while ($i < $num_rows) {
  282. $array = $db->fetch_array($resql);
  283. array_push($def, $array[0]);
  284. $i++;
  285. }
  286. } else {
  287. dol_print_error($db);
  288. }
  289. print "<table class=\"noborder\" width=\"100%\">\n";
  290. print "<tr class=\"liste_titre\">\n";
  291. print " <td>".$langs->trans("Name")."</td>\n";
  292. print " <td>".$langs->trans("Description")."</td>\n";
  293. print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n";
  294. print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n";
  295. print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
  296. print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
  297. print "</tr>\n";
  298. clearstatcache();
  299. foreach ($dirmodels as $reldir) {
  300. foreach (array('', '/doc') as $valdir) {
  301. $realpath = $reldir."core/modules/propale".$valdir;
  302. $dir = dol_buildpath($realpath);
  303. if (is_dir($dir)) {
  304. $handle = opendir($dir);
  305. if (is_resource($handle)) {
  306. while (($file = readdir($handle)) !== false) {
  307. $filelist[] = $file;
  308. }
  309. closedir($handle);
  310. arsort($filelist);
  311. foreach ($filelist as $file) {
  312. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  313. if (file_exists($dir.'/'.$file)) {
  314. $name = substr($file, 4, dol_strlen($file) - 16);
  315. $classname = substr($file, 0, dol_strlen($file) - 12);
  316. require_once $dir.'/'.$file;
  317. $module = new $classname($db);
  318. $modulequalified = 1;
  319. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  320. $modulequalified = 0;
  321. }
  322. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  323. $modulequalified = 0;
  324. }
  325. if ($modulequalified) {
  326. print '<tr class="oddeven"><td width="100">';
  327. print (empty($module->name) ? $name : $module->name);
  328. print "</td><td>\n";
  329. if (method_exists($module, 'info')) {
  330. print $module->info($langs);
  331. } else {
  332. print $module->description;
  333. }
  334. print '</td>';
  335. // Active
  336. if (in_array($name, $def)) {
  337. print '<td class="center">'."\n";
  338. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
  339. print img_picto($langs->trans("Enabled"), 'switch_on');
  340. print '</a>';
  341. print '</td>';
  342. } else {
  343. print "<td align=\"center\">\n";
  344. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  345. print "</td>";
  346. }
  347. // Defaut
  348. print "<td align=\"center\">";
  349. if ($conf->global->PROPALE_ADDON_PDF == "$name") {
  350. print img_picto($langs->trans("Default"), 'on');
  351. } else {
  352. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  353. }
  354. print '</td>';
  355. // Info
  356. $htmltooltip = $langs->trans("Name").': '.$module->name;
  357. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  358. if ($module->type == 'pdf') {
  359. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  360. }
  361. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  362. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  363. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  364. $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
  365. $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
  366. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  367. //$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
  368. //$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
  369. $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1);
  370. print '<td class="center">';
  371. print $form->textwithpicto('', $htmltooltip, 1, 0);
  372. print '</td>';
  373. // Preview
  374. print '<td class="center">';
  375. if ($module->type == 'pdf') {
  376. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  377. } else {
  378. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  379. }
  380. print '</td>';
  381. print "</tr>\n";
  382. }
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. print '</table>';
  391. /*
  392. * Payment mode
  393. */
  394. print '<br>';
  395. print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInProposal"), '', '');
  396. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  397. print '<input type="hidden" name="token" value="'.newToken().'" />';
  398. print '<table class="noborder centpercent">';
  399. print '<tr class="liste_titre">';
  400. print '<td>';
  401. print '<input type="hidden" name="action" value="setribchq">';
  402. print $langs->trans("PaymentMode").'</td>';
  403. print '<td align="right">';
  404. if (empty($conf->facture->enabled)) {
  405. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  406. }
  407. print '</td>';
  408. print "</tr>\n";
  409. print '<tr class="oddeven">';
  410. print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
  411. print "<td>";
  412. if (empty($conf->facture->enabled)) {
  413. if (!empty($conf->banque->enabled)) {
  414. $sql = "SELECT rowid, label";
  415. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  416. $sql .= " WHERE clos = 0";
  417. $sql .= " AND courant = 1";
  418. $sql .= " AND entity IN (".getEntity('bank_account').")";
  419. $resql = $db->query($sql);
  420. if ($resql) {
  421. $num = $db->num_rows($resql);
  422. $i = 0;
  423. if ($num > 0) {
  424. print '<select name="rib" class="flat" id="rib">';
  425. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  426. while ($i < $num) {
  427. $row = $db->fetch_row($resql);
  428. print '<option value="'.$row[0].'"';
  429. print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
  430. print '>'.$row[1].'</option>';
  431. $i++;
  432. }
  433. print "</select>";
  434. } else {
  435. print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
  436. }
  437. }
  438. } else {
  439. print '<span class="opacitymedium">'.$langs->trans("BankModuleNotActive").'</span>';
  440. }
  441. } else {
  442. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  443. }
  444. print "</td></tr>";
  445. print '<tr class="oddeven">';
  446. print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
  447. print "<td>";
  448. if (empty($conf->facture->enabled)) {
  449. print '<select class="flat" name="chq" id="chq">';
  450. print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
  451. print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
  452. $sql = "SELECT rowid, label";
  453. $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
  454. $sql .= " WHERE clos = 0";
  455. $sql .= " AND courant = 1";
  456. $sql .= " AND entity IN (".getEntity('bank_account').")";
  457. $resql = $db->query($sql);
  458. if ($resql) {
  459. $num = $db->num_rows($resql);
  460. $i = 0;
  461. while ($i < $num) {
  462. $row = $db->fetch_row($resql);
  463. print '<option value="'.$row[0].'"';
  464. print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
  465. print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
  466. $i++;
  467. }
  468. }
  469. print "</select>";
  470. } else {
  471. print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
  472. }
  473. print "</td></tr>";
  474. print "</table>";
  475. print "</form>";
  476. print '<br>';
  477. /*
  478. * Other options
  479. */
  480. print load_fiche_titre($langs->trans("OtherOptions"), '', '');
  481. print "<table class=\"noborder\" width=\"100%\">";
  482. print "<tr class=\"liste_titre\">";
  483. print "<td>".$langs->trans("Parameter")."</td>\n";
  484. print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
  485. print "<td>&nbsp;</td>\n";
  486. print "</tr>";
  487. print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
  488. print '<input type="hidden" name="token" value="'.newToken().'">';
  489. print "<input type=\"hidden\" name=\"action\" value=\"setdefaultduration\">";
  490. print '<tr class="oddeven">';
  491. print '<td>'.$langs->trans("DefaultProposalDurationValidity").'</td>';
  492. print '<td width="60" align="center">'."<input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_VALIDITY_DURATION."\"></td>";
  493. print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
  494. print '</tr>';
  495. print '</form>';
  496. /*
  497. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  498. print '<input type="hidden" name="token" value="'.newToken().'">';
  499. print '<input type="hidden" name="action" value="setusecustomercontactasrecipient">';
  500. print '<tr class="oddeven"><td>';
  501. print $langs->trans("UseCustomerContactAsPropalRecipientIfExist");
  502. print '</td><td width="60" align="center">';
  503. print $form->selectyesno("value",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1);
  504. print '</td><td class="right">';
  505. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  506. print "</td></tr>\n";
  507. print '</form>';
  508. */
  509. $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
  510. $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
  511. $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
  512. foreach ($substitutionarray as $key => $val) {
  513. $htmltext .= $key.'<br>';
  514. }
  515. $htmltext .= '</i>';
  516. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  517. print '<input type="hidden" name="token" value="'.newToken().'">';
  518. print '<input type="hidden" name="action" value="set_PROPOSAL_FREE_TEXT">';
  519. print '<tr class="oddeven"><td colspan="2">';
  520. print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
  521. $variablename = 'PROPOSAL_FREE_TEXT';
  522. if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
  523. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
  524. } else {
  525. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  526. $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
  527. print $doleditor->Create();
  528. }
  529. print '</td><td class="right">';
  530. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  531. print "</td></tr>\n";
  532. print '</form>';
  533. print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
  534. print '<input type="hidden" name="token" value="'.newToken().'">';
  535. print "<input type=\"hidden\" name=\"action\" value=\"set_PROPALE_DRAFT_WATERMARK\">";
  536. print '<tr class="oddeven"><td>';
  537. print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
  538. print '</td><td>';
  539. print '<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.$conf->global->PROPALE_DRAFT_WATERMARK.'">';
  540. print '</td><td class="right">';
  541. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  542. print "</td></tr>\n";
  543. print '</form>';
  544. /* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
  545. if ($conf->banque->enabled)
  546. {
  547. print '<tr class="oddeven"><td>';
  548. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp;</td><td class="right">';
  549. if (! empty($conf->use_javascript_ajax))
  550. {
  551. print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL');
  552. }
  553. else
  554. {
  555. if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL))
  556. {
  557. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  558. }
  559. else
  560. {
  561. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
  562. }
  563. }
  564. print '</td></tr>';
  565. }
  566. else
  567. {
  568. print '<tr class="oddeven"><td>';
  569. print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
  570. }
  571. */
  572. print '</table>';
  573. /*
  574. * Directory
  575. */
  576. print '<br>';
  577. print load_fiche_titre($langs->trans("PathToDocuments"), '', '');
  578. print "<table class=\"noborder\" width=\"100%\">\n";
  579. print "<tr class=\"liste_titre\">\n";
  580. print " <td>".$langs->trans("Name")."</td>\n";
  581. print " <td>".$langs->trans("Value")."</td>\n";
  582. print "</tr>\n";
  583. print "<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans("PathDirectory")."</td>\n <td>".$conf->propal->multidir_output[$conf->entity]."</td>\n</tr>\n";
  584. print "</table>\n<br>";
  585. /*
  586. * Notifications
  587. */
  588. print load_fiche_titre($langs->trans("Notifications"), '', '');
  589. print '<table class="noborder centpercent">';
  590. print '<tr class="liste_titre">';
  591. print '<td>'.$langs->trans("Parameter").'</td>';
  592. print '<td align="center" width="60"></td>';
  593. print '<td width="80">&nbsp;</td>';
  594. print "</tr>\n";
  595. print '<tr class="oddeven"><td colspan="2">';
  596. print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
  597. print '</td><td class="right">';
  598. print "</td></tr>\n";
  599. print '</table>';
  600. // End of page
  601. llxFooter();
  602. $db->close();