propal.php 26 KB

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