propal.php 26 KB

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