123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- <?php
- /* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
- * Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
- //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
- //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
- //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
- if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
- if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
- if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
- if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
- if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
- $_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS
- require '../main.inc.php'; // Load $user and permissions
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
- require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
- require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $place = GETPOST('place','int');
- if ($place=="") $place="0";
- $action = GETPOST('action','alpha');
- $langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter"));
- /*
- * View
- */
- // Title
- $title='TakePOS - Dolibarr '.DOL_VERSION;
- if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
- $head='<meta name="apple-mobile-web-app-title" content="TakePOS"/>
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="mobile-web-app-capable" content="yes">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>';
- top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
- ?>
- <link rel="stylesheet" href="css/pos.css">
- <script type="text/javascript" src="js/takepos.js" ></script>
- <link rel="stylesheet" href="css/colorbox.css" type="text/css" media="screen" />
- <script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
- <script language="javascript">
- <?php
- $categorie = new Categorie($db);
- $categories = $categorie->get_full_arbo('product');
- ?>
- var categories = JSON.parse( '<?php echo json_encode($categories);?>' );
- var currentcat;
- var pageproducts=0;
- var pagecategories=0;
- var pageactions=0;
- var place="<?php echo $place;?>";
- var editaction="qty";
- var editnumber="";
- function PrintCategories(first){
- for (i = 0; i < 14; i++) {
- if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break;
- $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
- $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
- $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']);
- }
- }
- function MoreCategories(moreorless){
- if (moreorless=="more"){
- $('#catimg15').animate({opacity: '0.5'}, 1);
- $('#catimg15').animate({opacity: '1'}, 100);
- pagecategories=pagecategories+1;
- }
- if (moreorless=="less"){
- $('#catimg14').animate({opacity: '0.5'}, 1);
- $('#catimg14').animate({opacity: '1'}, 100);
- if (pagecategories==0) return; //Return if no less pages
- pagecategories=pagecategories-1;
- }
- if (typeof (categories[14*pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
- pagecategories=pagecategories-1;
- return;
- }
- for (i = 0; i < 14; i++) {
- if (typeof (categories[i+(14*pagecategories)]) == "undefined"){
- $("#catdesc"+i).text("");
- $("#catimg"+i).attr("src","");
- continue;
- }
- $("#catdesc"+i).text(categories[i+(14*pagecategories)]['label']);
- $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[i+(14*pagecategories)]['rowid']);
- $("#catdiv"+i).data("rowid",categories[i+(14*pagecategories)]['rowid']);
- }
- }
- function LoadProducts(position){
- $('#catimg'+position).animate({opacity: '0.5'}, 1);
- $('#catimg'+position).animate({opacity: '1'}, 100);
- currentcat=$('#catdiv'+position).data('rowid');
- if (currentcat=="") return;
- pageproducts=0;
- $.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
- idata=0; //product data counter
- ishow=0; //product to show counter
- while (idata < 30) {
- if (typeof (data[idata]) == "undefined") {
- $("#prodesc"+ishow).text("");
- $("#proimg"+ishow).attr("src","");
- $("#prodiv"+ishow).data("rowid","");
- ishow++; //Next product to show after print data product
- }
- else if ((data[idata]['status']) == "1") {
- //Only show products with status=1 (for sell)
- $("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
- $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']);
- $("#prodiv"+ishow).data("rowid",data[idata]['id']);
- ishow++; //Next product to show after print data product
- }
- idata++; //Next data everytime
- }
- });
- }
- function MoreProducts(moreorless){
- if (moreorless=="more"){
- $('#proimg31').animate({opacity: '0.5'}, 1);
- $('#proimg31').animate({opacity: '1'}, 100);
- pageproducts=pageproducts+1;
- }
- if (moreorless=="less"){
- $('#proimg30').animate({opacity: '0.5'}, 1);
- $('#proimg30').animate({opacity: '1'}, 100);
- if (pageproducts==0) return; //Return if no less pages
- pageproducts=pageproducts-1;
- }
- $.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
- if (typeof (data[(30*pageproducts)]) == "undefined" && moreorless=="more"){ // Return if no more pages
- pageproducts=pageproducts-1;
- return;
- }
- idata=30*pageproducts; //product data counter
- ishow=0; //product to show counter
- while (idata < 30) {
- if (typeof (data[idata]) == "undefined") {
- $("#prodesc"+ishow).text("");
- $("#proimg"+ishow).attr("src","");
- $("#prodiv"+ishow).data("rowid","");
- ishow++; //Next product to show after print data product
- }
- else if ((data[idata]['status']) == "1") {
- //Only show products with status=1 (for sell)
- $("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
- $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']);
- $("#prodiv"+ishow).data("rowid",data[idata]['id']);
- ishow++; //Next product to show after print data product
- }
- idata++; //Next data everytime
- }
- });
- }
- function ClickProduct(position){
- $('#proimg'+position).animate({opacity: '0.5'}, 1);
- $('#proimg'+position).animate({opacity: '1'}, 100);
- idproduct=$('#prodiv'+position).data('rowid');
- if (idproduct=="") return;
- $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function deleteline(){
- $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function Customer(){
- $.colorbox({href:"customers.php?nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Customer");?>"});
- }
- function CloseBill(){
- $.colorbox({href:"pay.php?place="+place, width:"80%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("CloseBill");?>"});
- }
- function Floors(){
- $.colorbox({href:"floors.php?place="+place, width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors");?>"});
- }
- function FreeZone(){
- $.colorbox({href:"freezone.php?place="+place, onClosed: function () { Refresh(); },width:"80%", height:"30%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("FreeZone");?>"});
- }
- function Refresh(){
- $("#poslines").load("invoice.php?place="+place, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function Search(){
- $("#poslines").load("invoice.php?action=search&place="+place, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function Search2(){
- pageproducts=0;
- $.getJSON('./ajax.php?action=search&term='+$('#search').val(), function(data) {
- for (i = 0; i < 30; i++) {
- if (typeof (data[i]) == "undefined"){
- $("#prodesc"+i).text("");
- $("#proimg"+i).attr("src","");
- $("#prodiv"+i).data("rowid","");
- continue;
- }
- $("#prodesc"+i).text(data[parseInt(i)]['label']);
- $("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i]['rowid']);
- $("#prodiv"+i).data("rowid",data[i]['rowid']);
- }
- });
- }
- function Edit(number){
- var text=selectedtext+"<br> ";
- if (number=='c'){
- editnumber="";
- Refresh();
- return;
- }
- else if (number=='qty'){
- if (editaction=='qty' && editnumber!=""){
- $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>");
- });
- return;
- }
- else {
- editaction="qty";
- }
- }
- else if (number=='p'){
- if (editaction=='p' && editnumber!=""){
- $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#price").html("<?php echo $langs->trans("Price"); ?>");
- });
- return;
- }
- else {
- editaction="p";
- }
- }
- else if (number=='r'){
- if (editaction=='r' && editnumber!=""){
- $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() {
- editnumber="";
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
- });
- return;
- }
- else {
- editaction="r";
- }
- }
- else {
- editnumber=editnumber+number;
- }
- if (editaction=='qty'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Qty").": "; ?>";
- $("#qty").html("OK");
- $("#price").html("<?php echo $langs->trans("Price"); ?>");
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
- }
- if (editaction=='p'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("Price").": "; ?>";
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>");
- $("#price").html("OK");
- $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
- }
- if (editaction=='r'){
- text=text+"<?php echo $langs->trans("Modify")." -> ".$langs->trans("ReductionShort").": "; ?>";
- $("#qty").html("<?php echo $langs->trans("Qty"); ?>");
- $("#price").html("<?php echo $langs->trans("Price"); ?>");
- $("#reduction").html("OK");
- }
- $('#'+selectedline).find("td:first").html(text+editnumber);
- }
- function TakeposPrintingOrder(){
- $("#poslines").load("invoice.php?action=order&place="+place, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function TakeposPrintingTemp(){
- $("#poslines").load("invoice.php?action=temp&place="+place, function() {
- $('#poslines').scrollTop($('#poslines')[0].scrollHeight);
- });
- }
- function OpenDrawer(){
- $.ajax({
- type: "POST",
- url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
- data: "opendrawer"
- });
- }
- function MoreActions(totalactions){
- if (pageactions==0){
- pageactions=1;
- for (i = 0; i <= totalactions; i++){
- if (i<9) $("#action"+i).hide();
- else $("#action"+i).show();
- }
- }
- else if (pageactions==1){
- pageactions=0;
- for (i = 0; i <= totalactions; i++){
- if (i<9) $("#action"+i).show();
- else $("#action"+i).hide();
- }
- }
- }
- $( document ).ready(function() {
- PrintCategories(0);
- LoadProducts(0);
- Refresh();
- });
- </script>
- <body style="overflow: hidden; background-color:#E8E8E8;">
- <div class="container">
- <div class="row1">
- <div id="poslines" class="div1" style="overflow: auto;">
- </div>
- <div class="div2">
- <button type="button" class="calcbutton" onclick="Edit(7);">7</button>
- <button type="button" class="calcbutton" onclick="Edit(8);">8</button>
- <button type="button" class="calcbutton" onclick="Edit(9);">9</button>
- <button type="button" id="qty" class="calcbutton2" onclick="Edit('qty');"><?php echo $langs->trans("Qty"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(4);">4</button>
- <button type="button" class="calcbutton" onclick="Edit(5);">5</button>
- <button type="button" class="calcbutton" onclick="Edit(6);">6</button>
- <button type="button" id="price" class="calcbutton2" onclick="Edit('p');"><?php echo $langs->trans("Price"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(1);">1</button>
- <button type="button" class="calcbutton" onclick="Edit(2);">2</button>
- <button type="button" class="calcbutton" onclick="Edit(3);">3</button>
- <button type="button" id="reduction" class="calcbutton2" onclick="Edit('r');"><?php echo $langs->trans("ReductionShort"); ?></button>
- <button type="button" class="calcbutton" onclick="Edit(0);">0</button>
- <button type="button" class="calcbutton" onclick="Edit('.');">.</button>
- <button type="button" class="calcbutton" onclick="Edit('c');">C</button>
- <button type="button" class="calcbutton2" id="delete" style="color: red;" onclick="deleteline();"><b>X</b></button>
- </div>
- <?php
- // User menu and external TakePOS modules
- $menus = array();
- $r=0;
- $menus[$r++]=array('title'=>$langs->trans("SearchProduct"),
- 'action'=>'Search();');
- $menus[$r++]=array('title'=>$langs->trans("FreeZone"),
- 'action'=>'FreeZone();');
- $menus[$r++]=array('title'=>$langs->trans("Customer"),
- 'action'=>'Customer();');
- $menus[$r++]=array('title'=>$langs->trans("BackOffice"),
- 'action'=>'window.open(\''.DOL_URL_ROOT.'\', \'backoffice\');');
- $menus[$r++]=array('title'=>$langs->trans("ValidateBill"),
- 'action'=>'CloseBill();');
- $menus[$r++]=array('title'=>$langs->trans("Logout"),
- 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';');
- //BAR RESTAURANT specified menu
- if($conf->global->TAKEPOS_BAR_RESTAURANT){
- $menus[$r++]=array('title'=>$langs->trans("Floors"),
- 'action'=>'Floors();');
- if ($conf->global->TAKEPOS_ORDER_PRINTERS){
- $menus[$r++]=array('title'=>$langs->trans("Order"),
- 'action'=>'TakeposPrintingOrder();');
- }
- //add temp ticket button
- if ($conf->global->TAKEPOS_BAR_RESTAURANT){
- if ($conf->global->TAKEPOSCONNECTOR) $menus[$r++]=array('title'=>$langs->trans("Receipt"),'action'=>'TakeposPrinting(placeid);');
- else $menus[$r++]=array('title'=>$langs->trans("Receipt"),'action'=>'Print(placeid);');
- }
- }
- if ($conf->global->TAKEPOSCONNECTOR){
- $menus[$r++]=array('title'=>$langs->trans("DOL_OPEN_DRAWER"),
- 'action'=>'OpenDrawer();');
- }
- $hookmanager->initHooks(array('takeposfrontend'));
- $reshook=$hookmanager->executeHooks('ActionButtons');
- if (!empty($reshook))
- {
- $menus[$r++]=$reshook;
- }
- ?>
- <div class="div3">
- <?php
- $i = 0;
- foreach($menus as $menu) {
- $i++;
- if (count($menus)>9 and $i==9)
- {
- echo '<button type="button" id="actionnext" class="actionbutton" onclick="MoreActions('.count($menus).');">'.$langs->trans("Next").'</button>';
- echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
- }
- else if ($i>9) echo '<button style="display: none;" type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
- else echo '<button type="button" id="action'.$i.'" class="actionbutton" onclick="'.$menu['action'].'">'.$menu['title'].'</button>';
- }
- ?>
- </div>
- </div>
- <div class="row2">
- <div class="div4">
- <?php
- $count=0;
- while ($count<16)
- {
- ?>
- <div class='wrapper' <?php if ($count==14) echo 'onclick="MoreCategories(\'less\');"'; else if ($count==15) echo 'onclick="MoreCategories(\'more\');"'; else echo 'onclick="LoadProducts('.$count.');"';?> id='catdiv<?php echo $count;?>'>
- <img class='imgwrapper' <?php if ($count==14) echo 'src="img/arrow-prev-top.png"'; if ($count==15) echo 'src="img/arrow-next-top.png"';?> width="98%" id='catimg<?php echo $count;?>'/>
- <div class='description'>
- <div class='description_content' id='catdesc<?php echo $count;?>'></div>
- </div>
- </div>
- <?php
- $count++;
- }
- ?>
- </div>
- <div class="div5">
- <?php
- $count=0;
- while ($count<32)
- {
- ?>
- <div class='wrapper2' id='prodiv<?php echo $count;?>' <?php if ($count==30) {?> onclick="MoreProducts('less');" <?php } if ($count==31) {?> onclick="MoreProducts('more');" <?php } else echo 'onclick="ClickProduct('.$count.');"';?>>
- <img class='imgwrapper' <?php if ($count==30) echo 'src="img/arrow-prev-top.png"'; if ($count==31) echo 'src="img/arrow-next-top.png"';?> width="95%" id='proimg<?php echo $count;?>'/>
- <div class='description'>
- <div class='description_content' id='prodesc<?php echo $count;?>'></div>
- </div>
- </div>
- <?php
- $count++;
- }
- ?>
- </div>
- </div>
- </div>
- </body>
- <?php
- llxFooter();
- $db->close();
|