propal.php 24 KB

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