facturation1.tpl.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
  3. * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  5. * Copyright (C) 2015 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. // Protection to avoid direct call of template
  23. if (empty($langs) || !is_object($langs))
  24. {
  25. print "Error, template page can't be called as URL";
  26. exit;
  27. }
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("main", "bills", "cashdesk"));
  30. // Object $form must de defined
  31. ?>
  32. <script type="text/javascript" src="javascript/facturation1.js"></script>
  33. <script type="text/javascript" src="javascript/dhtml.js"></script>
  34. <script type="text/javascript" src="javascript/keypad.js"></script>
  35. <!-- ========================= Cadre "Article" ============================= -->
  36. <fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Article"); ?></legend>
  37. <form id="frmFacturation" class="formulaire1" method="post" action="facturation_verif.php" autocomplete="off">
  38. <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
  39. <input type="hidden" name="hdnSource" value="NULL" />
  40. <table class="center">
  41. <tr><th class="label1"><?php echo $langs->trans("FilterRefOrLabelOrBC"); ?></th><th class="label1"><?php echo $langs->trans("Designation"); ?></th></tr>
  42. <tr>
  43. <!-- Affichage de la reference et de la designation -->
  44. <!-- Suppression de l'attribut onkeyup qui causait un probleme d'emulation avec les douchettes -->
  45. <td><input class="texte_ref" type="text" id ="txtRef" name="txtRef" value="<?php echo $obj_facturation->ref() ?>"
  46. onchange="javascript: setSource('REF');"
  47. onfocus="javascript: this.select();" />
  48. </td>
  49. <td class="select_design maxwidthonsmartphone">
  50. <select id="selProduit" class="maxwidthonsmartphone" name="selProduit" onchange="javascript: setSource('LISTE');">
  51. <?php
  52. print '<option value="0">'.$top_liste_produits.'</option>'."\n";
  53. $id = $obj_facturation->id();
  54. // Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ...
  55. $nbtoshow = $nbr_enreg;
  56. if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes;
  57. for ($i = 0; $i < $nbtoshow; $i++)
  58. {
  59. if ($id == $tab_designations[$i]['rowid']) {
  60. $selected = 'selected';
  61. } else {
  62. $selected = '';
  63. }
  64. $label = $tab_designations[$i]['label'];
  65. print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.dol_trunc($tab_designations[$i]['ref'], 16).' - '.dol_trunc($label, 35, 'middle');
  66. if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot) && $tab_designations[$i]['fk_product_type'] == 0) {
  67. print ' ('.$langs->trans("CashDeskStock").': '.(empty($tab_designations[$i]['reel']) ? 0 : $tab_designations[$i]['reel']).')';
  68. }
  69. print '</option>'."\n";
  70. }
  71. ?>
  72. </select>
  73. </td>
  74. </tr>
  75. </table>
  76. </form>
  77. <form id="frmQte" class="formulaire1" method="post" action="facturation_verif.php?action=ajout_article" onsubmit ="javascript: return verifSaisie();">
  78. <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
  79. <table class="center">
  80. <tr>
  81. <th><?php echo $langs->trans("Qty"); ?></th>
  82. <th><?php echo $langs->trans("PriceUHT"); ?></th>
  83. <th><?php echo $langs->trans("Discount"); ?> (%)</th>
  84. <th><?php echo $langs->trans("VATRate"); ?></th>
  85. <th></th>
  86. </tr>
  87. <tr>
  88. <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" />
  89. <?php print genkeypad("txtQte", "frmQte"); ?>
  90. </td>
  91. <!-- Show unit price -->
  92. <?php // TODO Remove the disabled and use this value when adding product into cart ?>
  93. <td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td>
  94. <!-- Choix de la remise -->
  95. <td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
  96. <?php print genkeypad("txtRemise", "frmQte"); ?>
  97. </td>
  98. <!-- Choix du taux de TVA -->
  99. <td class="select_tva center">
  100. <?php
  101. $vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected
  102. $buyer = new Societe($db);
  103. if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
  104. echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1);
  105. ?>
  106. </td>
  107. <td></td>
  108. </tr>
  109. <tr>
  110. <!-- Affichage du stock pour l'article courant -->
  111. <tr>
  112. <td><?php echo $langs->trans("Stock"); ?></td>
  113. <td>
  114. <input class="texte1_off maxwidth50onsmartphone" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled />
  115. </td>
  116. <td><?php echo $langs->trans("TotalHT"); ?></td>
  117. <!-- Affichage du total HT -->
  118. <td colspan="2"><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td>
  119. </tr>
  120. </table>
  121. <input class="button bouton_ajout_article" type="submit" id="sbmtEnvoyer" value="<?php echo $langs->trans("AddThisArticle"); ?>" />
  122. </form>
  123. </fieldset>
  124. <!-- ========================= Cadre "Amount" ============================= -->
  125. <form id="frmDifference" class="formulaire1" method="post" onsubmit="javascript: return verifReglement()" action="validation_verif.php?action=valide_achat">
  126. <input type="hidden" name="hdnChoix" value="" />
  127. <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
  128. <fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Amount"); ?></legend>
  129. <table class="centpercent">
  130. <tr><th class="label1"><?php echo $langs->trans("TotalTicket"); ?></th><th class="label1"><?php echo $langs->trans("Received"); ?></th><th class="label1"><?php echo $langs->trans("Change"); ?></th></tr>
  131. <tr>
  132. <!-- Affichage du montant du -->
  133. <td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->prixTotalTtc(), 'MT'); ?>" disabled /></td>
  134. <!-- Choix du montant encaisse -->
  135. <td><input class="texte2 maxwidth100onsmartphone" type="text" id="txtEncaisse" name="txtEncaisse" value="" onkeyup="javascript: verifDifference();" onfocus="javascript: this.select();" />
  136. <?php print genkeypad("txtEncaisse", "frmDifference"); ?>
  137. </td>
  138. <!-- Affichage du montant rendu -->
  139. <td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtRendu" value="0" disabled /></td>
  140. </tr>
  141. <tr>
  142. </table>
  143. </fieldset>
  144. <fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("PaymentMode"); ?></legend>
  145. <div class="inline-block">
  146. <?php
  147. print '<div class="inline-block" style="margin: 6px;">';
  148. if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0)
  149. {
  150. $langs->load("errors");
  151. print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
  152. }
  153. else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
  154. print '</div>';
  155. print '<div class="inline-block" style="margin: 6px;">';
  156. if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
  157. {
  158. $langs->load("errors");
  159. print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
  160. }
  161. else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
  162. print '</div>';
  163. print '<div class="inline-block" style="margin: 6px;">';
  164. if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
  165. {
  166. $langs->load("errors");
  167. print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
  168. }
  169. else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
  170. print '</div>';
  171. print '<div class="clearboth">';
  172. print '<div class="inline-block" style="margin: 6px;">';
  173. ?>
  174. <input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="<?php echo $langs->trans("Reported"); ?>" onclick="javascript: verifClic('DIF');" />
  175. <?php
  176. print $langs->trans("DateDue").' :';
  177. print $form->selectDate(-1, 'txtDatePaiement', 0, 0, 0, 'paymentmode', 1, 0);
  178. print '</div>';
  179. ?>
  180. </div>
  181. </fieldset>
  182. </form>
  183. <script type="text/javascript">
  184. /* Calendar.setup ({
  185. inputField : "txtDatePaiement",
  186. ifFormat : "%Y-%m-%d",
  187. button : "btnCalendrier"
  188. });
  189. */
  190. if (document.getElementById('frmFacturation').txtRef.value) {
  191. modif();
  192. document.getElementById('frmQte').txtQte.focus();
  193. document.getElementById('frmQte').txtQte.select();
  194. } else {
  195. document.getElementById('frmFacturation').txtRef.focus();
  196. }
  197. </script>