2018-09-28 13:31:41 +02:00
< ? php
/* Copyright ( C ) 2018 Andreu Bisquerra < jove @ bisquerra . com >
2019-01-11 20:09:38 +01:00
* Copyright ( C ) 2019 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2020-08-29 16:07:01 +02:00
* Copyright ( C ) 2020 Thibault FOUCART < support @ ptibogxiv . net >
2018-09-28 13:31:41 +02:00
*
* 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-09-28 13:31:41 +02:00
*/
2019-03-28 09:56:01 +01:00
/**
2020-03-16 15:41:21 +01:00
* \file htdocs / takepos / index . php
2019-03-28 09:56:01 +01:00
* \ingroup takepos
* \brief Main TakePOS screen
*/
2018-09-28 13:31:41 +02:00
//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
2020-10-25 20:06:50 +01:00
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
2021-02-26 21:17:52 +01:00
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' );
}
2018-09-28 13:31:41 +02:00
2019-11-08 15:51:54 +01:00
require '../main.inc.php' ; // Load $user and permissions
2020-04-12 18:15:38 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
2018-09-28 13:31:41 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2020-01-01 21:54:47 +01:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
2018-09-28 13:31:41 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2019-03-27 17:50:23 +01:00
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2019-01-23 20:59:34 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' ;
2021-02-05 17:30:41 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2018-09-28 13:31:41 +02:00
2020-03-23 15:02:15 +01:00
$place = ( GETPOST ( 'place' , 'aZ09' ) ? GETPOST ( 'place' , 'aZ09' ) : 0 ); // $place is id of table for Bar or Restaurant or multiple sales
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-05-08 18:29:00 +02:00
$setterminal = GETPOST ( 'setterminal' , 'int' );
2020-10-03 22:13:32 +02:00
$setcurrency = GETPOST ( 'setcurrency' , 'aZ09' );
2019-05-08 18:29:00 +02:00
2022-04-08 00:42:39 +02:00
if ( empty ( $_SESSION [ " takeposterminal " ])) {
2022-08-31 14:55:53 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_NUM_TERMINALS' ) == 1 ) {
2021-02-26 21:17:52 +01:00
$_SESSION [ " takeposterminal " ] = 1 ; // Use terminal 1 if there is only 1 terminal
} elseif ( ! empty ( $_COOKIE [ " takeposterminal " ])) {
$_SESSION [ " takeposterminal " ] = preg_replace ( '/[^a-zA-Z0-9_\-]/' , '' , $_COOKIE [ " takeposterminal " ]); // Restore takeposterminal from previous session
}
2020-08-30 09:19:35 +02:00
}
2021-02-26 21:17:52 +01:00
if ( $setterminal > 0 ) {
2019-11-08 15:51:54 +01:00
$_SESSION [ " takeposterminal " ] = $setterminal ;
2021-08-04 14:38:05 +02:00
setcookie ( " takeposterminal " , $setterminal , ( time () + ( 86400 * 354 )), '/' , null , ( empty ( $dolibarr_main_force_https ) ? false : true ), true ); // Permanent takeposterminal var in a cookie
2019-05-08 18:29:00 +02:00
}
2018-09-28 13:31:41 +02:00
2021-02-26 21:17:52 +01:00
if ( $setcurrency != " " ) {
2020-10-03 22:13:32 +02:00
$_SESSION [ " takeposcustomercurrency " ] = $setcurrency ;
2021-07-06 03:53:42 +02:00
// We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code.
2020-10-03 22:13:32 +02:00
}
2020-03-16 15:41:21 +01:00
$_SESSION [ " urlfrom " ] = '/takepos/index.php' ;
2019-08-28 13:22:54 +02:00
2020-03-30 20:05:45 +02:00
$langs -> loadLangs ( array ( " bills " , " orders " , " commercial " , " cashdesk " , " receiptprinter " , " banks " ));
2018-09-28 13:31:41 +02:00
2019-03-15 01:28:54 +01:00
$categorie = new Categorie ( $db );
2020-01-27 01:31:39 +01:00
$maxcategbydefaultforthisdevice = 12 ;
$maxproductbydefaultforthisdevice = 24 ;
2021-02-26 21:17:52 +01:00
if ( $conf -> browser -> layout == 'phone' ) {
2020-10-31 14:32:18 +01:00
$maxcategbydefaultforthisdevice = 8 ;
$maxproductbydefaultforthisdevice = 16 ;
2019-05-26 16:44:17 +02:00
//REDIRECT TO BASIC LAYOUT IF TERMINAL SELECTED AND BASIC MOBILE LAYOUT ENABLED
2021-02-26 21:17:52 +01:00
if ( $_SESSION [ " takeposterminal " ] != " " && $conf -> global -> TAKEPOS_PHONE_BASIC_LAYOUT == 1 ) {
2019-11-08 15:51:54 +01:00
$_SESSION [ " basiclayout " ] = 1 ;
2019-10-16 16:26:00 +02:00
header ( " Location: phone.php?mobilepage=invoice " );
2019-05-26 16:44:17 +02:00
exit ;
}
2019-03-29 11:45:40 +01:00
}
2019-11-08 15:51:54 +01:00
$MAXCATEG = ( empty ( $conf -> global -> TAKEPOS_NB_MAXCATEG ) ? $maxcategbydefaultforthisdevice : $conf -> global -> TAKEPOS_NB_MAXCATEG );
$MAXPRODUCT = ( empty ( $conf -> global -> TAKEPOS_NB_MAXPRODUCT ) ? $maxproductbydefaultforthisdevice : $conf -> global -> TAKEPOS_NB_MAXPRODUCT );
2019-03-15 01:28:54 +01:00
2020-01-01 21:54:47 +01:00
/*
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY' . $_SESSION [ " takeposterminal " ];
$soc = new Societe ( $db );
if ( $invoice -> socid > 0 ) $soc -> fetch ( $invoice -> socid );
else $soc -> fetch ( $conf -> global -> $constforcompanyid );
*/
2020-01-25 14:23:23 +01:00
// Security check
$result = restrictedArea ( $user , 'takepos' , 0 , '' );
2018-09-28 13:31:41 +02:00
2020-04-12 18:15:38 +02:00
2018-09-28 13:31:41 +02:00
/*
* View
*/
2020-04-12 18:15:38 +02:00
$form = new Form ( $db );
2022-04-08 00:42:39 +02:00
$disablejs = 0 ;
$disablehead = 0 ;
$arrayofjs = array ();
$arrayofcss = array ();
2018-09-28 13:31:41 +02:00
// Title
2019-11-08 15:51:54 +01:00
$title = 'TakePOS - Dolibarr ' . DOL_VERSION ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) {
$title = 'TakePOS - ' . $conf -> global -> MAIN_APPLICATION_TITLE ;
}
2019-11-08 15:51:54 +01:00
$head = ' < meta name = " apple-mobile-web-app-title " content = " TakePOS " />
2018-12-17 22:43:02 +01:00
< 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 " /> ' ;
2018-09-28 13:31:41 +02:00
top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss );
?>
2020-01-27 02:06:34 +01:00
< link rel = " stylesheet " href = " css/pos.css.php " >
2018-09-28 13:31:41 +02:00
< link rel = " stylesheet " href = " css/colorbox.css " type = " text/css " media = " screen " />
2020-01-19 19:16:45 +01:00
< ? php
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_COLOR_THEME' ) == 1 ) {
2021-02-26 21:17:52 +01:00
print '<link rel="stylesheet" href="css/colorful.css">' ;
}
2020-01-19 19:16:45 +01:00
?>
2019-03-27 17:50:23 +01:00
< script type = " text/javascript " src = " js/jquery.colorbox-min.js " ></ script > <!-- TODO It seems we don ' t need this -->
2021-11-29 15:09:18 +01:00
< script type = " text/javascript " >
2018-09-28 13:31:41 +02:00
< ? php
2022-04-08 00:42:39 +02:00
$categories = $categorie -> get_full_arbo ( 'product' , (( getDolGlobalInt ( 'TAKEPOS_ROOT_CATEGORY_ID' ) > 0 ) ? getDolGlobalInt ( 'TAKEPOS_ROOT_CATEGORY_ID' ) : 0 ), 1 );
2019-03-15 01:28:54 +01:00
// Search root category to know its level
2019-03-27 20:20:39 +01:00
//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0;
2019-11-08 15:51:54 +01:00
$levelofrootcategory = 0 ;
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_ROOT_CATEGORY_ID' ) > 0 ) {
2021-02-26 21:17:52 +01:00
foreach ( $categories as $key => $categorycursor ) {
2022-04-08 00:42:39 +02:00
if ( $categorycursor [ 'id' ] == getDolGlobalInt ( 'TAKEPOS_ROOT_CATEGORY_ID' )) {
2020-10-31 14:32:18 +01:00
$levelofrootcategory = $categorycursor [ 'level' ];
break ;
}
}
2019-03-15 01:28:54 +01:00
}
2021-02-14 22:44:04 +01:00
2019-03-15 01:28:54 +01:00
$levelofmaincategories = $levelofrootcategory + 1 ;
2019-01-27 21:49:48 +01:00
2019-03-15 00:49:44 +01:00
$maincategories = array ();
$subcategories = array ();
2021-02-26 21:17:52 +01:00
foreach ( $categories as $key => $categorycursor ) {
if ( $categorycursor [ 'level' ] == $levelofmaincategories ) {
2020-10-31 14:32:18 +01:00
$maincategories [ $key ] = $categorycursor ;
} else {
$subcategories [ $key ] = $categorycursor ;
}
2019-03-15 00:49:44 +01:00
}
2019-03-14 16:35:36 +01:00
2020-03-09 17:56:09 +01:00
$maincategories = dol_sort_array ( $maincategories , 'label' );
$subcategories = dol_sort_array ( $subcategories , 'label' );
2018-09-28 13:31:41 +02:00
?>
2019-02-01 15:33:36 +01:00
2019-03-14 16:35:36 +01:00
var categories = < ? php echo json_encode ( $maincategories ); ?> ;
2019-02-01 15:33:36 +01:00
var subcategories = < ? php echo json_encode ( $subcategories ); ?> ;
2018-09-28 13:31:41 +02:00
var currentcat ;
var pageproducts = 0 ;
var pagecategories = 0 ;
2018-12-19 22:52:16 +01:00
var pageactions = 0 ;
2019-11-08 15:51:54 +01:00
var place = " <?php echo $place ; ?> " ;
2018-09-28 13:31:41 +02:00
var editaction = " qty " ;
var editnumber = " " ;
2021-01-02 15:36:19 +01:00
var invoiceid = 0 ;
2021-09-07 14:48:30 +02:00
var search2_timer = null ;
2019-03-28 18:51:04 +01:00
2019-03-29 11:45:40 +01:00
/*
var app = this ;
app . hasKeyboard = false ;
this . keyboardPress = function () {
2021-02-26 21:17:52 +01:00
app . hasKeyboard = true ;
$ ( window ) . unbind ( " keyup " , app . keyboardPress );
localStorage . hasKeyboard = true ;
console . log ( " has keyboard! " )
2019-03-29 11:45:40 +01:00
}
$ ( window ) . on ( " keyup " , app . keyboardPress )
if ( localStorage . hasKeyboard ) {
2021-02-26 21:17:52 +01:00
app . hasKeyboard = true ;
$ ( window ) . unbind ( " keyup " , app . keyboardPress );
console . log ( " has keyboard from localStorage " )
2019-03-29 11:45:40 +01:00
}
*/
function ClearSearch () {
console . log ( " ClearSearch " );
$ ( " #search " ) . val ( '' );
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " <?php echo $langs->trans ( " Qty " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #price " ) . html ( " <?php echo $langs->trans ( " Price " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #reduction " ) . html ( " <?php echo $langs->trans ( " ReductionShort " ); ?> " ) . removeClass ( 'clicked' );
2019-09-02 21:26:44 +02:00
< ? php if ( $conf -> browser -> layout == 'classic' ) { ?>
2019-03-29 11:45:40 +01:00
setFocusOnSearchField ();
< ? php } ?>
}
// Set the focus on search field but only on desktop. On tablet or smartphone, we don't to avoid to have the keyboard open automatically
function setFocusOnSearchField () {
2020-03-16 15:41:21 +01:00
console . log ( " Call setFocusOnSearchField in page index.php " );
2019-03-29 12:19:23 +01:00
< ? php if ( $conf -> browser -> layout == 'classic' ) { ?>
2019-03-29 11:45:40 +01:00
console . log ( " has keyboard from localStorage, so we can force focus on search field " );
$ ( " #search " ) . focus ();
2019-03-29 12:19:23 +01:00
< ? php } ?>
2019-03-29 11:45:40 +01:00
}
2019-03-27 15:42:53 +01:00
function PrintCategories ( first ) {
2019-03-28 18:51:04 +01:00
console . log ( " PrintCategories " );
2019-03-27 19:34:13 +01:00
for ( i = 0 ; i < < ? php echo ( $MAXCATEG - 2 ); ?> ; i++) {
2019-03-28 18:51:04 +01:00
if ( typeof ( categories [ parseInt ( i ) + parseInt ( first )]) == " undefined " )
{
2019-03-29 11:45:40 +01:00
$ ( " #catdivdesc " + i ) . hide ();
2019-03-28 18:51:04 +01:00
$ ( " #catdesc " + i ) . text ( " " );
$ ( " #catimg " + i ) . attr ( " src " , " genimg/empty.png " );
$ ( " #catwatermark " + i ) . hide ();
2019-12-04 21:30:31 +01:00
$ ( " #catdiv " + i ) . attr ( 'class' , 'wrapper divempty' );
2019-03-28 18:51:04 +01:00
continue ;
}
2019-03-29 11:45:40 +01:00
$ ( " #catdivdesc " + i ) . show ();
2021-11-30 16:19:36 +01:00
< ? php
2022-05-08 20:28:37 +02:00
if ( getDolGlobalString ( 'TAKEPOS_SHOW_CATEGORY_DESCRIPTION' ) == 1 ) { ?>
2021-12-01 09:58:01 +01:00
$ ( " #catdesc " + i ) . html ( categories [ parseInt ( i ) + parseInt ( first )][ 'label' ] . bold () + ' - ' + categories [ parseInt ( i ) + parseInt ( first )][ 'description' ]);
2021-11-30 16:19:36 +01:00
< ? php } else { ?>
$ ( " #catdesc " + i ) . text ( categories [ parseInt ( i ) + parseInt ( first )][ 'label' ]);
< ? php } ?>
2021-02-26 21:17:52 +01:00
$ ( " #catimg " + i ) . attr ( " src " , " genimg/index.php?query=cat&id= " + categories [ parseInt ( i ) + parseInt ( first )][ 'rowid' ]);
$ ( " #catdiv " + i ) . data ( " rowid " , categories [ parseInt ( i ) + parseInt ( first )][ 'rowid' ]);
2019-12-04 21:30:31 +01:00
$ ( " #catdiv " + i ) . attr ( 'class' , 'wrapper' );
2019-02-24 21:15:11 +01:00
$ ( " #catwatermark " + i ) . show ();
2018-09-28 13:31:41 +02:00
}
}
2019-03-27 15:42:53 +01:00
function MoreCategories ( moreorless ) {
2019-03-27 19:34:13 +01:00
console . log ( " MoreCategories moreorless= " + moreorless + " pagecategories= " + pagecategories );
if ( moreorless == " more " ) {
2018-12-17 22:43:02 +01:00
$ ( '#catimg15' ) . animate ({ opacity : '0.5' }, 1 );
2018-09-28 13:31:41 +02:00
$ ( '#catimg15' ) . animate ({ opacity : '1' }, 100 );
pagecategories = pagecategories + 1 ;
}
2019-03-27 19:34:13 +01:00
if ( moreorless == " less " ) {
2018-12-17 22:43:02 +01:00
$ ( '#catimg14' ) . animate ({ opacity : '0.5' }, 1 );
2018-09-28 13:31:41 +02:00
$ ( '#catimg14' ) . animate ({ opacity : '1' }, 100 );
if ( pagecategories == 0 ) return ; //Return if no less pages
pagecategories = pagecategories - 1 ;
}
2019-03-27 19:34:13 +01:00
if ( typeof ( categories [ < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
2018-09-28 13:31:41 +02:00
pagecategories = pagecategories - 1 ;
return ;
}
2019-03-27 19:34:13 +01:00
for ( i = 0 ; i < < ? php echo ( $MAXCATEG - 2 ); ?> ; i++) {
if ( typeof ( categories [ i + ( < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories)]) == "undefined") {
2019-03-29 11:45:40 +01:00
$ ( " #catdivdesc " + i ) . hide ();
2019-03-27 19:34:13 +01:00
$ ( " #catdesc " + i ) . text ( " " );
$ ( " #catimg " + i ) . attr ( " src " , " genimg/empty.png " );
$ ( " #catwatermark " + i ) . hide ();
continue ;
}
2019-03-29 11:45:40 +01:00
$ ( " #catdivdesc " + i ) . show ();
2021-11-30 16:19:36 +01:00
< ? php
2022-05-08 20:28:37 +02:00
if ( getDolGlobalString ( 'TAKEPOS_SHOW_CATEGORY_DESCRIPTION' ) == 1 ) { ?>
2021-11-30 16:19:36 +01:00
$ ( " #catdesc " + i ) . html ( categories [ i + ( < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories)]['label'].bold() + ' - ' + categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['description']);
< ? php } else { ?>
$ ( " #catdesc " + i ) . text ( categories [ i + ( < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories)]['label']);
< ? php } ?>
2021-02-26 21:17:52 +01:00
$ ( " #catimg " + i ) . attr ( " src " , " genimg/index.php?query=cat&id= " + categories [ i + ( < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories)]['rowid']);
$ ( " #catdiv " + i ) . data ( " rowid " , categories [ i + ( < ? php echo ( $MAXCATEG - 2 ); ?> * pagecategories)]['rowid']);
2019-02-24 21:15:11 +01:00
$ ( " #catwatermark " + i ) . show ();
2018-09-28 13:31:41 +02:00
}
2019-03-28 18:51:04 +01:00
2019-03-29 11:45:40 +01:00
ClearSearch ();
2018-09-28 13:31:41 +02:00
}
2019-09-27 10:19:27 +02:00
// LoadProducts
function LoadProducts ( position , issubcat ) {
2019-03-28 18:51:04 +01:00
console . log ( " LoadProducts " );
2019-03-27 17:50:23 +01:00
var maxproduct = < ? php echo ( $MAXPRODUCT - 2 ); ?> ;
2019-12-08 23:16:49 +01:00
if ( position == " supplements " ) currentcat = " supplements " ;
else
{
$ ( '#catimg' + position ) . animate ({ opacity : '0.5' }, 1 );
$ ( '#catimg' + position ) . animate ({ opacity : '1' }, 100 );
if ( issubcat == true ) currentcat = $ ( '#prodiv' + position ) . data ( 'rowid' );
else currentcat = $ ( '#catdiv' + position ) . data ( 'rowid' );
}
2021-02-26 21:17:52 +01:00
if ( currentcat == undefined ) return ;
2018-09-28 13:31:41 +02:00
pageproducts = 0 ;
2019-01-27 21:49:48 +01:00
ishow = 0 ; //product to show counter
2019-02-03 14:29:45 +01:00
2019-01-27 21:49:48 +01:00
jQuery . each ( subcategories , function ( i , val ) {
2019-03-27 17:50:23 +01:00
if ( currentcat == val . fk_parent ) {
2019-03-29 11:45:40 +01:00
$ ( " #prodivdesc " + ishow ) . show ();
2022-05-08 20:28:37 +02:00
< ? php if ( getDolGlobalString ( 'TAKEPOS_SHOW_CATEGORY_DESCRIPTION' ) == 1 ) { ?>
2021-11-30 18:22:59 +01:00
$ ( " #prodesc " + ishow ) . html ( val . label . bold () + ' - ' + val . description );
2022-05-08 20:33:23 +02:00
$ ( " #probutton " + ishow ) . html ( val . label );
2021-11-30 18:22:59 +01:00
< ? php } else { ?>
$ ( " #prodesc " + ishow ) . text ( val . label );
2022-05-08 20:33:23 +02:00
$ ( " #probutton " + ishow ) . text ( val . label );
2021-11-30 18:22:59 +01:00
< ? php } ?>
2021-05-23 09:55:01 +02:00
$ ( " #probutton " + ishow ) . show ();
2020-03-16 18:04:22 +01:00
$ ( " #proprice " + ishow ) . attr ( " class " , " hidden " );
$ ( " #proprice " + ishow ) . html ( " " );
2019-02-27 04:21:12 +01:00
$ ( " #proimg " + ishow ) . attr ( " src " , " genimg/index.php?query=cat&id= " + val . rowid );
2019-01-27 21:49:48 +01:00
$ ( " #prodiv " + ishow ) . data ( " rowid " , val . rowid );
$ ( " #prodiv " + ishow ) . data ( " iscat " , 1 );
2019-02-24 21:15:11 +01:00
$ ( " #prowatermark " + ishow ) . show ();
2019-01-27 21:49:48 +01:00
ishow ++ ;
}
});
2019-02-03 14:29:45 +01:00
idata = 0 ; //product data counter
2019-09-27 10:19:27 +02:00
$ . getJSON ( '<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category=' + currentcat , function ( data ) {
2019-10-03 17:40:59 +02:00
console . log ( " Call ajax.php (in LoadProducts) to get Products of category " + currentcat + " then loop on result to fill image thumbs " );
2019-10-20 15:16:40 +02:00
console . log ( data );
2019-03-27 17:50:23 +01:00
while ( ishow < maxproduct ) {
2019-03-27 17:50:57 +01:00
//console.log("ishow"+ishow+" idata="+idata);
2019-10-03 17:40:59 +02:00
console . log ( data [ idata ]);
2019-01-11 20:09:38 +01:00
if ( typeof ( data [ idata ]) == " undefined " ) {
2022-04-08 00:42:39 +02:00
< ? php if ( ! getDolGlobalString ( 'TAKEPOS_HIDE_PRODUCT_IMAGES' )) {
2020-09-16 06:54:01 +02:00
echo '$("#prodivdesc"+ishow).hide();' ;
echo '$("#prodesc"+ishow).text("");' ;
echo '$("#proimg"+ishow).attr("title","");' ;
echo '$("#proimg"+ishow).attr("src","genimg/empty.png");' ;
2020-09-16 07:59:36 +02:00
} else {
2020-09-16 06:54:01 +02:00
echo '$("#probutton"+ishow).hide();' ;
echo '$("#probutton"+ishow).text("");' ;
} ?>
2020-03-16 18:04:22 +01:00
$ ( " #proprice " + ishow ) . attr ( " class " , " hidden " );
$ ( " #proprice " + ishow ) . html ( " " );
2019-01-11 20:09:38 +01:00
$ ( " #prodiv " + ishow ) . data ( " rowid " , " " );
2019-12-04 21:30:31 +01:00
$ ( " #prodiv " + ishow ) . attr ( " class " , " wrapper2 divempty " );
2019-03-27 17:50:23 +01:00
$ ( " #prowatermark " + ishow ) . hide ();
2019-01-11 20:09:38 +01:00
ishow ++ ; //Next product to show after print data product
}
2019-03-27 17:50:23 +01:00
else if (( data [ idata ][ 'status' ]) == " 1 " ) { // Only show products with status=1 (for sell)
2020-03-16 18:04:22 +01:00
< ? php
$titlestring = " ' " . dol_escape_js ( $langs -> transnoentities ( 'Ref' ) . ': ' ) . " ' + data[idata]['ref'] " ;
$titlestring .= " + ' - " . dol_escape_js ( $langs -> trans ( " Barcode " ) . ': ' ) . " ' + data[idata]['barcode'] " ;
?>
var titlestring = < ? php echo $titlestring ; ?> ;
2022-04-08 00:42:39 +02:00
< ? php if ( ! getDolGlobalString ( 'TAKEPOS_HIDE_PRODUCT_IMAGES' )) {
2020-09-16 06:54:01 +02:00
echo '$("#prodivdesc"+ishow).show();' ;
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_SHOW_PRODUCT_REFERENCE' ) == 1 ) {
2021-11-30 15:41:46 +01:00
echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);' ;
} else {
2022-04-21 07:39:51 +02:00
echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);' ;
2021-11-30 15:41:46 +01:00
}
2020-09-16 06:54:01 +02:00
echo '$("#proimg"+ishow).attr("title", titlestring);' ;
echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);' ;
2021-02-26 21:17:52 +01:00
} else {
2020-09-16 06:54:01 +02:00
echo '$("#probutton"+ishow).show();' ;
2022-04-21 07:39:51 +02:00
echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);' ;
2020-09-16 06:54:01 +02:00
}
?>
2020-03-16 18:04:22 +01:00
if ( data [ parseInt ( idata )][ 'price_formated' ]) {
$ ( " #proprice " + ishow ) . attr ( " class " , " productprice " );
$ ( " #proprice " + ishow ) . html ( data [ parseInt ( idata )][ 'price_formated' ]);
}
2019-10-03 17:40:59 +02:00
$ ( " #prodiv " + ishow ) . data ( " rowid " , data [ idata ][ 'id' ]);
$ ( " #prodiv " + ishow ) . data ( " iscat " , 0 );
2019-12-04 21:30:31 +01:00
$ ( " #prodiv " + ishow ) . attr ( " class " , " wrapper2 " );
2019-03-27 17:50:23 +01:00
$ ( " #prowatermark " + ishow ) . hide ();
2019-01-11 20:09:38 +01:00
ishow ++ ; //Next product to show after print data product
2022-04-20 14:47:36 +02:00
< ? php
// Add js from hooks
$parameters = array ();
$parameters [ 'caller' ] = 'loadProducts' ;
$hookmanager -> executeHooks ( 'completeJSProductDisplay' , $parameters );
print $hookmanager -> resPrint ;
?>
2018-09-28 13:31:41 +02:00
}
2019-03-27 17:50:23 +01:00
//console.log("Hide the prowatermark for ishow="+ishow);
2019-01-11 20:09:38 +01:00
idata ++ ; //Next data everytime
2018-09-28 13:31:41 +02:00
}
});
2019-03-28 18:51:04 +01:00
2019-03-29 11:45:40 +01:00
ClearSearch ();
2018-09-28 13:31:41 +02:00
}
2019-03-27 17:50:23 +01:00
function MoreProducts ( moreorless ) {
2019-03-28 18:51:04 +01:00
console . log ( " MoreProducts " );
2022-04-29 09:49:10 +02:00
if ( $ ( '#search_pagination' ) . val () != '' ) return Search2 ( '<?php echo $keyCodeForEnter; ?>' , moreorless );
2019-03-27 17:50:23 +01:00
var maxproduct = < ? php echo ( $MAXPRODUCT - 2 ); ?> ;
2018-09-28 13:31:41 +02:00
if ( moreorless == " more " ){
2018-12-17 22:43:02 +01:00
$ ( '#proimg31' ) . animate ({ opacity : '0.5' }, 1 );
2018-09-28 13:31:41 +02:00
$ ( '#proimg31' ) . animate ({ opacity : '1' }, 100 );
pageproducts = pageproducts + 1 ;
}
if ( moreorless == " less " ){
2018-12-17 22:43:02 +01:00
$ ( '#proimg30' ) . animate ({ opacity : '0.5' }, 1 );
2018-09-28 13:31:41 +02:00
$ ( '#proimg30' ) . animate ({ opacity : '1' }, 100 );
if ( pageproducts == 0 ) return ; //Return if no less pages
pageproducts = pageproducts - 1 ;
}
2019-09-27 10:19:27 +02:00
$ . getJSON ( '<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getProducts&category=' + currentcat , function ( data ) {
2019-03-27 17:50:23 +01:00
console . log ( " Call ajax.php (in MoreProducts) to get Products of category " + currentcat );
if ( typeof ( data [( maxproduct * pageproducts )]) == " undefined " && moreorless == " more " ){ // Return if no more pages
2018-09-28 13:31:41 +02:00
pageproducts = pageproducts - 1 ;
return ;
}
2019-03-27 19:34:13 +01:00
idata =< ? php echo ( $MAXPRODUCT - 2 ); ?> * pageproducts; //product data counter
2019-01-11 20:09:38 +01:00
ishow = 0 ; //product to show counter
2019-03-27 17:50:23 +01:00
while ( ishow < maxproduct ) {
2019-01-11 20:09:38 +01:00
if ( typeof ( data [ idata ]) == " undefined " ) {
2019-03-29 11:45:40 +01:00
$ ( " #prodivdesc " + ishow ) . hide ();
2019-02-03 14:29:45 +01:00
$ ( " #prodesc " + ishow ) . text ( " " );
2021-05-23 09:55:01 +02:00
$ ( " #probutton " + ishow ) . text ( " " );
$ ( " #probutton " + ishow ) . hide ();
2020-03-16 18:04:22 +01:00
$ ( " #proprice " + ishow ) . attr ( " class " , " " );
$ ( " #proprice " + ishow ) . html ( " " );
2019-02-24 21:15:11 +01:00
$ ( " #proimg " + ishow ) . attr ( " src " , " genimg/empty.png " );
2019-01-11 20:09:38 +01:00
$ ( " #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)
2019-03-29 11:45:40 +01:00
$ ( " #prodivdesc " + ishow ) . show ();
2021-11-30 15:41:46 +01:00
< ? php
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_SHOW_PRODUCT_REFERENCE' ) == 1 ) { ?>
2021-11-30 15:41:46 +01:00
$ ( " #prodesc " + ishow ) . html ( data [ parseInt ( idata )][ 'ref' ] . bold () + ' - ' + data [ parseInt ( idata )][ 'label' ]);
< ? php } else { ?>
2022-04-21 07:39:51 +02:00
$ ( " #prodesc " + ishow ) . html ( data [ parseInt ( idata )][ 'label' ]);
2021-11-30 15:41:46 +01:00
< ? php } ?>
2022-04-21 07:39:51 +02:00
$ ( " #probutton " + ishow ) . html ( data [ parseInt ( idata )][ 'label' ]);
2021-05-23 09:55:01 +02:00
$ ( " #probutton " + ishow ) . show ();
2020-03-16 18:04:22 +01:00
if ( data [ parseInt ( idata )][ 'price_formated' ]) {
$ ( " #proprice " + ishow ) . attr ( " class " , " productprice " );
$ ( " #proprice " + ishow ) . html ( data [ parseInt ( idata )][ 'price_formated' ]);
}
2019-02-27 04:21:12 +01:00
$ ( " #proimg " + ishow ) . attr ( " src " , " genimg/index.php?query=pro&id= " + data [ idata ][ 'id' ]);
2019-01-11 20:09:38 +01:00
$ ( " #prodiv " + ishow ) . data ( " rowid " , data [ idata ][ 'id' ]);
2019-01-27 21:49:48 +01:00
$ ( " #prodiv " + ishow ) . data ( " iscat " , 0 );
2019-01-11 20:09:38 +01:00
ishow ++ ; //Next product to show after print data product
2018-09-28 13:31:41 +02:00
}
2019-02-24 21:15:11 +01:00
$ ( " #prowatermark " + ishow ) . hide ();
2019-01-11 20:09:38 +01:00
idata ++ ; //Next data everytime
2018-09-28 13:31:41 +02:00
}
});
2019-03-28 18:51:04 +01:00
2019-03-29 11:45:40 +01:00
ClearSearch ();
2018-09-28 13:31:41 +02:00
}
2022-02-09 16:37:41 +01:00
function ClickProduct ( position , qty = 1 ) {
2019-03-28 18:51:04 +01:00
console . log ( " ClickProduct " );
2021-02-26 21:17:52 +01:00
$ ( '#proimg' + position ) . animate ({ opacity : '0.5' }, 1 );
2018-09-28 13:31:41 +02:00
$ ( '#proimg' + position ) . animate ({ opacity : '1' }, 100 );
2019-01-27 21:49:48 +01:00
if ( $ ( '#prodiv' + position ) . data ( 'iscat' ) == 1 ){
2019-03-27 17:50:23 +01:00
console . log ( " Click on a category at position " + position );
2019-01-27 21:49:48 +01:00
LoadProducts ( position , true );
}
else {
idproduct = $ ( '#prodiv' + position ) . data ( 'rowid' );
2022-02-09 16:37:41 +01:00
console . log ( " Click on product at position " + position + " for idproduct " + idproduct + " , qty= " + qty );
2019-01-27 21:49:48 +01:00
if ( idproduct == " " ) return ;
2019-03-27 17:50:23 +01:00
// Call page invoice.php to generate the section with product lines
2022-02-09 16:37:41 +01:00
$ ( " #poslines " ) . load ( " invoice.php?action=addline&token=<?php echo newToken() ?>&place= " + place + " &idproduct= " + idproduct + " &selectedline= " + selectedline + " &qty= " + qty , function () {
2021-08-08 19:15:18 +02:00
< ? php if ( ! empty ( $conf -> global -> TAKEPOS_CUSTOMER_DISPLAY )) echo " CustomerDisplay(); " ; ?>
2019-01-27 21:49:48 +01:00
});
}
2019-03-28 19:33:22 +01:00
2019-03-29 11:45:40 +01:00
ClearSearch ();
2018-09-28 13:31:41 +02:00
}
2020-08-29 16:07:01 +02:00
function ChangeThirdparty ( idcustomer ) {
console . log ( " ChangeThirdparty " );
// Call page list.php to change customer
2020-09-29 17:10:08 +02:00
$ ( " #poslines " ) . load ( " ../societe/list.php?action=change&type=t&contextpage=poslist&idcustomer= " + idcustomer + " &place= " + place + " " , function () {
2020-08-29 16:07:01 +02:00
});
ClearSearch ();
}
2019-03-27 17:50:23 +01:00
function deleteline () {
2019-03-28 18:51:04 +01:00
console . log ( " Delete line " );
2020-10-01 10:50:54 +02:00
$ ( " #poslines " ) . load ( " invoice.php?action=deleteline&token=<?php echo newToken(); ?>&place= " + place + " &idline= " + selectedline , function () {
2019-03-27 20:20:39 +01:00
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2018-09-28 13:31:41 +02:00
});
2019-09-03 11:37:25 +02:00
ClearSearch ();
2018-09-28 13:31:41 +02:00
}
2019-03-27 17:50:23 +01:00
function Customer () {
2019-08-01 12:23:02 +02:00
console . log ( " Open box to select the thirdparty place= " + place );
2020-09-29 17:10:08 +02:00
$ . colorbox ({ href : " ../societe/list.php?type=t&contextpage=poslist&nomassaction=1&place= " + place , width : " 90% " , height : " 80% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " Customer " ); ?> " });
2018-09-28 13:31:41 +02:00
}
2019-04-28 18:12:33 +02:00
function History ()
{
2021-02-26 21:17:52 +01:00
console . log ( " Open box to select the history " );
$ . colorbox ({ href : " ../compta/facture/list.php?contextpage=poslist " , width : " 90% " , height : " 80% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " History " ); ?> " });
2019-04-28 18:12:33 +02:00
}
2020-03-11 12:30:07 +01:00
function Reduction () {
invoiceid = $ ( " #invoiceid " ) . val ();
console . log ( " Open popup to enter reduction on invoiceid= " + invoiceid );
$ . colorbox ({ href : " reduction.php?place= " + place + " &invoiceid= " + invoiceid , width : " 80% " , height : " 90% " , transition : " none " , iframe : " true " , title : " " });
}
2019-03-27 17:50:23 +01:00
function CloseBill () {
2019-03-27 15:42:53 +01:00
invoiceid = $ ( " #invoiceid " ) . val ();
console . log ( " Open popup to enter payment on invoiceid= " + invoiceid );
$ . colorbox ({ href : " pay.php?place= " + place + " &invoiceid= " + invoiceid , width : " 80% " , height : " 90% " , transition : " none " , iframe : " true " , title : " " });
2018-09-28 13:31:41 +02:00
}
2021-08-21 22:29:18 +02:00
function Split () {
invoiceid = $ ( " #invoiceid " ) . val ();
console . log ( " Open popup to split on invoiceid= " + invoiceid );
$ . colorbox ({ href : " split.php?place= " + place + " &invoiceid= " + invoiceid , width : " 80% " , height : " 90% " , transition : " none " , iframe : " true " , title : " " });
}
2019-03-27 17:50:23 +01:00
function Floors () {
2020-06-30 12:07:24 +02:00
console . log ( " Open box to select floor place= " + place );
2019-11-08 15:51:54 +01:00
$ . colorbox ({ href : " floors.php?place= " + place , width : " 90% " , height : " 90% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " Floors " ); ?> " });
2018-09-28 13:31:41 +02:00
}
2019-03-27 17:50:23 +01:00
function FreeZone () {
2019-03-28 18:51:04 +01:00
console . log ( " Open box to enter a free product " );
2021-01-06 22:08:53 +01:00
$ . colorbox ({ href : " freezone.php?action=freezone&place= " + place , width : " 80% " , height : " 200px " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " FreeZone " ); ?> " });
2019-03-03 12:50:36 +01:00
}
2019-03-27 17:50:23 +01:00
function TakeposOrderNotes () {
2019-03-28 18:51:04 +01:00
console . log ( " Open box to order notes " );
2021-04-14 00:15:02 +02:00
ModalBox ( 'ModalNote' );
$ ( " #textinput " ) . focus ();
2018-09-28 13:31:41 +02:00
}
2019-03-27 17:50:23 +01:00
function Refresh () {
2021-01-02 15:36:19 +01:00
console . log ( " Refresh by reloading place= " + place + " invoiceid= " + invoiceid );
$ ( " #poslines " ) . load ( " invoice.php?place= " + place + " &invoiceid= " + invoiceid , function () {
2019-03-27 20:20:39 +01:00
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2018-09-28 13:31:41 +02:00
});
}
2019-04-02 17:36:27 +02:00
function New () {
2019-08-27 15:39:35 +02:00
// If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
2020-03-09 17:40:32 +01:00
invoiceid = $ ( " #invoiceid " ) . val ();
2020-12-30 21:22:54 +01:00
console . log ( " New with place = <?php echo $place ; ?>, js place= " + place + " , invoiceid= " + invoiceid );
2020-03-09 17:40:32 +01:00
$ . getJSON ( '<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&id=' + invoiceid , function ( data ) {
var r ;
if ( parseInt ( data [ 'paye' ]) === 1 ) {
r = true ;
} else {
r = confirm ( '<?php echo ($place > 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>' );
}
if ( r == true ) {
2020-07-07 03:50:14 +02:00
// Reload section with invoice lines
2020-10-01 10:50:54 +02:00
$ ( " #poslines " ) . load ( " invoice.php?action=delete&token=<?php echo newToken(); ?>&place= " + place , function () {
2020-03-09 17:40:32 +01:00
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
ClearSearch ();
}
});
2019-04-02 17:36:27 +02:00
}
2020-02-24 13:57:36 +01:00
/**
* Search products
*
2022-11-06 22:47:56 +01:00
* @ param string keyCodeForEnter Key code for " enter " or '' if not
* @ param int moreorless ? ?
* return void
2020-02-24 13:57:36 +01:00
*/
2022-04-29 10:00:25 +02:00
function Search2 ( keyCodeForEnter , moreorless ) {
2022-10-11 22:08:26 +02:00
var eventKeyCode = window . event . keyCode ;
console . log ( " Search2 Call ajax search to replace products keyCodeForEnter= " + keyCodeForEnter + " , eventKeyCode= " + eventKeyCode );
2020-03-10 14:08:28 +01:00
2022-04-29 10:00:25 +02:00
var search_term = $ ( '#search' ) . val ();
var search_start = 0 ;
var search_limit = < ? php echo $MAXPRODUCT - 2 ; ?> ;
if ( moreorless != null ) {
search_term = $ ( '#search_pagination' ) . val ();
search_start = $ ( '#search_start_' + moreorless ) . val ();
}
2022-11-06 22:47:56 +01:00
console . log ( " search_term= " + search_term );
2022-05-06 10:32:12 +02:00
if ( search_term == '' ) {
2022-04-20 17:46:16 +02:00
$ ( " [id^=prowatermark] " ) . html ( " " );
$ ( " [id^=prodesc] " ) . text ( " " );
$ ( " [id^=probutton] " ) . text ( " " );
$ ( " [id^=probutton] " ) . hide ();
$ ( " [id^=proprice] " ) . attr ( " class " , " hidden " );
$ ( " [id^=proprice] " ) . html ( " " );
$ ( " [id^=proimg] " ) . attr ( " src " , " genimg/empty.png " );
$ ( " [id^=prodiv] " ) . data ( " rowid " , " " );
return ;
}
2020-03-10 14:08:28 +01:00
var search = false ;
2022-11-06 22:47:56 +01:00
if ( keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter ) {
2020-03-10 14:08:28 +01:00
search = true ;
}
if ( search === true ) {
2022-10-11 22:08:26 +02:00
// if a timer has been already started (search2_timer is a global js variable), we cancel it now
// we click onto another key, we will restart another timer just after
2021-09-07 14:48:30 +02:00
if ( search2_timer ) {
clearTimeout ( search2_timer );
}
2022-10-11 22:08:26 +02:00
// temporization time to give time to type
2021-09-07 14:48:30 +02:00
search2_timer = setTimeout ( function (){
pageproducts = 0 ;
jQuery ( " .wrapper2 .catwatermark " ) . hide ();
2022-04-29 10:00:25 +02:00
var nbsearchresults = 0 ;
$ . getJSON ( '<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit , function ( data ) {
2021-09-07 14:48:30 +02:00
for ( i = 0 ; i < < ? php echo $MAXPRODUCT ?> ; i++) {
if ( typeof ( data [ i ]) == " undefined " ) {
2022-04-20 17:46:16 +02:00
$ ( " #prowatermark " + i ) . html ( " " );
2021-09-07 14:48:30 +02:00
$ ( " #prodesc " + i ) . text ( " " );
$ ( " #probutton " + i ) . text ( " " );
$ ( " #probutton " + i ) . hide ();
$ ( " #proprice " + i ) . attr ( " class " , " hidden " );
$ ( " #proprice " + i ) . html ( " " );
$ ( " #proimg " + i ) . attr ( " src " , " genimg/empty.png " );
$ ( " #prodiv " + i ) . data ( " rowid " , " " );
continue ;
}
< ? php
$titlestring = " ' " . dol_escape_js ( $langs -> transnoentities ( 'Ref' ) . ': ' ) . " ' + data[i]['ref'] " ;
$titlestring .= " + ' - " . dol_escape_js ( $langs -> trans ( " Barcode " ) . ': ' ) . " ' + data[i]['barcode'] " ;
?>
var titlestring = < ? php echo $titlestring ; ?> ;
2021-11-30 15:41:46 +01:00
< ? php
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_SHOW_PRODUCT_REFERENCE' ) == 1 ) { ?>
2021-11-30 15:41:46 +01:00
$ ( " #prodesc " + i ) . html ( data [ i ][ 'ref' ] . bold () + ' - ' + data [ i ][ 'label' ]);
< ? php } else { ?>
2022-04-21 07:39:51 +02:00
$ ( " #prodesc " + i ) . html ( data [ i ][ 'label' ]);
2021-11-30 15:41:46 +01:00
< ? php } ?>
2021-09-07 14:48:30 +02:00
$ ( " #prodivdesc " + i ) . show ();
2022-04-21 07:39:51 +02:00
$ ( " #probutton " + i ) . html ( data [ i ][ 'label' ]);
2021-09-07 14:48:30 +02:00
$ ( " #probutton " + i ) . show ();
if ( data [ i ][ 'price_formated' ]) {
$ ( " #proprice " + i ) . attr ( " class " , " productprice " );
$ ( " #proprice " + i ) . html ( data [ i ][ 'price_formated' ]);
}
$ ( " #proimg " + i ) . attr ( " title " , titlestring );
2021-09-07 15:02:27 +02:00
if ( undefined !== data [ i ][ 'img' ]) {
$ ( " #proimg " + i ) . attr ( " src " , data [ i ][ 'img' ]);
}
else {
$ ( " #proimg " + i ) . attr ( " src " , " genimg/index.php?query=pro&id= " + data [ i ][ 'rowid' ]);
}
2021-09-07 14:48:30 +02:00
$ ( " #prodiv " + i ) . data ( " rowid " , data [ i ][ 'rowid' ]);
$ ( " #prodiv " + i ) . data ( " iscat " , 0 );
2022-05-04 01:18:43 +02:00
2022-04-20 14:47:36 +02:00
< ? php
// Add js from hooks
$parameters = array ();
$parameters [ 'caller' ] = 'search2' ;
$hookmanager -> executeHooks ( 'completeJSProductDisplay' , $parameters );
print $hookmanager -> resPrint ;
?>
2022-05-04 01:18:43 +02:00
2022-04-29 10:00:25 +02:00
nbsearchresults ++ ;
2020-09-18 16:00:47 +02:00
}
2021-09-07 14:48:30 +02:00
}) . always ( function ( data ) {
// If there is only 1 answer
if ( $ ( '#search' ) . val () . length > 0 && data . length == 1 ) {
console . log ( $ ( '#search' ) . val () + ' - ' + data [ 0 ][ 'barcode' ]);
if ( $ ( '#search' ) . val () == data [ 0 ][ 'barcode' ] && 'thirdparty' == data [ 0 ][ 'object' ]) {
console . log ( " There is only 1 answer with barcode matching the search, so we change the thirdparty " + data [ 0 ][ 'rowid' ]);
ChangeThirdparty ( data [ 0 ][ 'rowid' ]);
}
2022-09-12 12:25:15 +02:00
else if ( $ ( '#search' ) . val () == data [ 0 ][ 'barcode' ] && 'product' == data [ 0 ][ 'object' ]) {
console . log ( " There is only 1 answer and we found search on a barcode, so we add the product in basket, qty= " + data [ 0 ][ 'qty' ]);
2022-02-09 16:37:41 +01:00
ClickProduct ( 0 , data [ 0 ][ 'qty' ]);
2021-09-07 14:48:30 +02:00
}
2020-03-16 18:04:22 +01:00
}
2021-09-07 14:48:30 +02:00
if ( eventKeyCode == keyCodeForEnter ){
if ( data . length == 0 ) {
$ ( '#search' ) . val ( ' < ? php
$langs -> load ( 'errors' );
2022-10-11 22:08:26 +02:00
echo dol_escape_js ( $langs -> transnoentitiesnoconv ( " ErrorRecordNotFoundShort " ));
?> ('+search_term+')');
2021-09-07 14:48:30 +02:00
$ ( '#search' ) . select ();
}
else ClearSearch ();
2020-08-04 08:11:44 +02:00
}
2022-04-29 10:00:25 +02:00
// memorize search_term and start for pagination
$ ( " #search_pagination " ) . val ( $ ( " #search " ) . val ());
if ( search_start == 0 ) {
$ ( " #prodiv<?php echo $MAXPRODUCT - 2; ?> span " ) . hide ();
}
else {
$ ( " #prodiv<?php echo $MAXPRODUCT - 2; ?> span " ) . show ();
var search_start_less = Math . max ( 0 , parseInt ( search_start ) - parseInt ( < ? php echo $MAXPRODUCT - 2 ; ?> ));
$ ( " #search_start_less " ) . val ( search_start_less );
}
if ( nbsearchresults != < ? php echo $MAXPRODUCT - 2 ; ?> ) {
$ ( " #prodiv<?php echo $MAXPRODUCT - 1; ?> span " ) . hide ();
}
else {
$ ( " #prodiv<?php echo $MAXPRODUCT - 1; ?> span " ) . show ();
var search_start_more = parseInt ( search_start ) + parseInt ( < ? php echo $MAXPRODUCT - 2 ; ?> );
$ ( " #search_start_more " ) . val ( search_start_more );
}
2021-09-07 14:48:30 +02:00
});
2021-09-09 03:42:12 +02:00
}, 500 ); // 500ms delay
2020-03-10 14:08:28 +01:00
}
2020-09-18 16:00:47 +02:00
2018-09-28 13:31:41 +02:00
}
2022-06-08 02:55:45 +02:00
/* Function called on an action into the PAD */
2019-03-28 18:51:04 +01:00
function Edit ( number ) {
2022-06-08 02:55:45 +02:00
console . log ( " We click on PAD on key= " + number );
2019-03-28 18:51:04 +01:00
2021-12-06 02:13:15 +01:00
if ( typeof ( selectedtext ) == " undefined " ) {
return ; // We click on an action on the number pad but there is no line selected
}
2019-03-28 18:51:04 +01:00
2021-02-26 21:17:52 +01:00
var text = selectedtext + " <br> " ;
2021-12-06 02:13:15 +01:00
2022-06-08 02:55:45 +02:00
if ( number == 'c' ) {
editnumber = '' ;
2021-02-26 21:17:52 +01:00
Refresh ();
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " <?php echo $langs->trans ( " Qty " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #price " ) . html ( " <?php echo $langs->trans ( " Price " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #reduction " ) . html ( " <?php echo $langs->trans ( " ReductionShort " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
return ;
2022-06-08 02:55:45 +02:00
} else if ( number == 'qty' ) {
if ( editaction == 'qty' && editnumber != '' ) {
2021-02-26 21:17:52 +01:00
$ ( " #poslines " ) . load ( " invoice.php?action=updateqty&place= " + place + " &idline= " + selectedline + " &number= " + editnumber , function () {
editnumber = " " ;
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " <?php echo $langs->trans ( " Qty " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
});
setFocusOnSearchField ();
return ;
}
else {
editaction = " qty " ;
}
2022-06-08 02:55:45 +02:00
} else if ( number == 'p' ) {
if ( editaction == 'p' && editnumber != " " ) {
2021-02-26 21:17:52 +01:00
$ ( " #poslines " ) . load ( " invoice.php?action=updateprice&place= " + place + " &idline= " + selectedline + " &number= " + editnumber , function () {
editnumber = " " ;
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2022-06-08 02:55:45 +02:00
$ ( " #price " ) . html ( " <?php echo $langs->trans ( " Price " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
});
ClearSearch ();
return ;
}
else {
editaction = " p " ;
}
2022-06-08 02:55:45 +02:00
} else if ( number == 'r' ) {
if ( editaction == 'r' && editnumber != " " ) {
2021-02-26 21:17:52 +01:00
$ ( " #poslines " ) . load ( " invoice.php?action=updatereduction&place= " + place + " &idline= " + selectedline + " &number= " + editnumber , function () {
editnumber = " " ;
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2022-06-08 02:55:45 +02:00
$ ( " #reduction " ) . html ( " <?php echo $langs->trans ( " ReductionShort " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
});
ClearSearch ();
return ;
}
else {
editaction = " r " ;
}
}
else {
editnumber = editnumber + number ;
}
if ( editaction == 'qty' ){
text = text + " <?php echo $langs->trans ( " Modify " ). " -> " . $langs->trans ( " Qty " ). " : " ; ?> " ;
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " OK " ) . addClass ( " clicked " );
$ ( " #price " ) . html ( " <?php echo $langs->trans ( " Price " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #reduction " ) . html ( " <?php echo $langs->trans ( " ReductionShort " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
}
if ( editaction == 'p' ){
text = text + " <?php echo $langs->trans ( " Modify " ). " -> " . $langs->trans ( " Price " ). " : " ; ?> " ;
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " <?php echo $langs->trans ( " Qty " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #price " ) . html ( " OK " ) . addClass ( " clicked " );
$ ( " #reduction " ) . html ( " <?php echo $langs->trans ( " ReductionShort " ); ?> " ) . removeClass ( 'clicked' );
2021-02-26 21:17:52 +01:00
}
if ( editaction == 'r' ){
text = text + " <?php echo $langs->trans ( " Modify " ). " -> " . $langs->trans ( " ReductionShort " ). " : " ; ?> " ;
2022-06-08 02:55:45 +02:00
$ ( " #qty " ) . html ( " <?php echo $langs->trans ( " Qty " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #price " ) . html ( " <?php echo $langs->trans ( " Price " ); ?> " ) . removeClass ( 'clicked' );
$ ( " #reduction " ) . html ( " OK " ) . addClass ( " clicked " );
2021-02-26 21:17:52 +01:00
}
$ ( '#' + selectedline ) . find ( " td:first " ) . html ( text + editnumber );
2018-09-28 13:31:41 +02:00
}
2021-12-06 02:13:15 +01:00
2018-09-28 13:31:41 +02:00
function TakeposPrintingOrder (){
2019-03-28 18:51:04 +01:00
console . log ( " TakeposPrintingOrder " );
2018-09-28 13:31:41 +02:00
$ ( " #poslines " ) . load ( " invoice.php?action=order&place= " + place , function () {
2019-03-27 20:20:39 +01:00
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2018-09-28 13:31:41 +02:00
});
}
2018-12-07 00:40:00 +01:00
function TakeposPrintingTemp (){
2019-03-28 18:51:04 +01:00
console . log ( " TakeposPrintingTemp " );
2018-12-07 00:40:00 +01:00
$ ( " #poslines " ) . load ( " invoice.php?action=temp&place= " + place , function () {
2019-03-27 20:20:39 +01:00
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
2018-12-07 00:40:00 +01:00
});
}
2018-11-21 16:54:40 +01:00
function OpenDrawer (){
2021-07-08 12:17:32 +02:00
console . log ( " OpenDrawer call ajax url http://<?php print getDolGlobalString('TAKEPOS_PRINT_SERVER'); ?>:8111/print " );
2018-11-21 16:54:40 +01:00
$ . ajax ({
2019-11-03 15:06:20 +01:00
type : " POST " ,
2021-06-17 03:37:52 +02:00
data : { token : 'notrequired' },
2020-12-19 22:28:16 +01:00
< ? php
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' ) && filter_var ( $conf -> global -> TAKEPOS_PRINT_SERVER , FILTER_VALIDATE_URL ) == true ) {
2022-04-08 00:42:39 +02:00
echo " url: ' " . getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' , 'localhost' ) . " /printer/drawer.php', " ;
2021-02-26 21:17:52 +01:00
} else {
2022-04-08 00:42:39 +02:00
echo " url: 'http:// " . getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' , 'localhost' ) . " :8111/print', " ;
2021-02-26 21:17:52 +01:00
}
2020-12-19 22:28:16 +01:00
?>
2019-11-03 15:06:20 +01:00
data : " opendrawer "
});
2018-11-21 16:54:40 +01:00
}
2019-11-03 15:06:20 +01:00
function DolibarrOpenDrawer () {
2021-06-17 03:37:52 +02:00
console . log ( " DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term=<?php print urlencode( $_SESSION["takeposterminal"] ); ?> " );
2019-11-03 15:06:20 +01:00
$ . ajax ({
type : " GET " ,
2021-06-17 03:37:52 +02:00
data : { token : '<?php echo currentToken(); ?>' },
url : " <?php print DOL_URL_ROOT.'/takepos/ajax/ajax.php?action=opendrawer&term='.urlencode( $_SESSION["takeposterminal"] ); ?> " ,
2019-11-03 15:06:20 +01:00
});
2019-11-03 00:50:58 +01:00
}
2018-12-19 22:52:16 +01:00
function MoreActions ( totalactions ){
if ( pageactions == 0 ){
pageactions = 1 ;
for ( i = 0 ; i <= totalactions ; i ++ ){
2020-04-11 16:31:08 +02:00
if ( i < 12 ) $ ( " #action " + i ) . hide ();
2018-12-19 22:52:16 +01:00
else $ ( " #action " + i ) . show ();
}
}
else if ( pageactions == 1 ){
pageactions = 0 ;
2019-02-03 14:29:45 +01:00
for ( i = 0 ; i <= totalactions ; i ++ ){
2020-04-11 16:31:08 +02:00
if ( i < 12 ) $ ( " #action " + i ) . show ();
2018-12-19 22:52:16 +01:00
else $ ( " #action " + i ) . hide ();
}
2019-02-03 14:29:45 +01:00
}
2018-12-19 22:52:16 +01:00
}
2020-03-30 20:05:45 +02:00
function ControlCashOpening ()
{
2021-02-26 21:17:52 +01:00
$ . colorbox ({ href : " ../compta/cashcontrol/cashcontrol_card.php?action=create&contextpage=takepos " , width : " 90% " , height : " 60% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " NewCashFence " ); ?> " });
2020-03-30 20:05:45 +02:00
}
function CloseCashFence ( rowid )
{
2021-02-26 21:17:52 +01:00
$ . colorbox ({ href : " ../compta/cashcontrol/cashcontrol_card.php?id= " + rowid + " &contextpage=takepos " , width : " 90% " , height : " 90% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " NewCashFence " ); ?> " });
2020-03-30 20:05:45 +02:00
}
function CashReport ( rowid )
{
2021-02-26 21:17:52 +01:00
$ . colorbox ({ href : " ../compta/cashcontrol/report.php?id= " + rowid + " &contextpage=takepos " , width : " 60% " , height : " 90% " , transition : " none " , iframe : " true " , title : " <?php echo $langs->trans ( " CashReport " ); ?> " });
2020-03-30 20:05:45 +02:00
}
2020-10-03 22:13:32 +02:00
// TakePOS Popup
function ModalBox ( ModalID )
2019-05-08 18:29:00 +02:00
{
2021-02-26 21:17:52 +01:00
var modal = document . getElementById ( ModalID );
2020-09-27 11:11:31 +02:00
modal . style . display = " block " ;
2019-05-08 18:29:00 +02:00
}
2019-08-20 23:44:30 +02:00
function DirectPayment (){
console . log ( " DirectPayment " );
2021-11-20 09:55:04 +01:00
$ ( " #poslines " ) . load ( " invoice.php?place= " + place + " &action=valid&pay=LIQ " , function () {
2019-08-20 23:44:30 +02:00
});
}
2020-01-27 01:31:39 +01:00
function FullScreen () {
document . documentElement . requestFullscreen ();
}
2020-09-13 21:12:14 +02:00
function WeighingScale (){
console . log ( " Weighing Scale " );
2021-02-26 21:17:52 +01:00
$ . ajax ({
type : " POST " ,
2021-06-17 03:37:52 +02:00
data : { token : 'notrequired' },
2021-07-08 12:17:32 +02:00
url : '<?php print getDolGlobalString(' TAKEPOS_PRINT_SERVER '); ?>/scale/index.php' ,
2021-02-26 21:17:52 +01:00
})
2020-09-13 21:12:14 +02:00
. done ( function ( editnumber ) {
$ ( " #poslines " ) . load ( " invoice.php?action=updateqty&place= " + place + " &idline= " + selectedline + " &number= " + editnumber , function () {
2021-02-26 21:17:52 +01:00
editnumber = " " ;
});
2020-09-13 21:12:14 +02:00
});
}
2018-09-28 13:31:41 +02:00
$ ( document ) . ready ( function () {
2021-02-26 21:17:52 +01:00
PrintCategories ( 0 );
2018-09-28 13:31:41 +02:00
LoadProducts ( 0 );
Refresh ();
2019-05-08 18:29:00 +02:00
< ? php
2019-05-24 08:36:43 +02:00
//IF NO TERMINAL SELECTED
2021-02-26 21:17:52 +01:00
if ( $_SESSION [ " takeposterminal " ] == " " ) {
2020-10-03 22:13:32 +02:00
print " ModalBox('ModalTerminal'); " ;
2019-05-24 08:36:43 +02:00
}
2021-11-11 16:14:48 +01:00
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_CONTROL_CASH_OPENING' )) {
2021-02-26 21:17:52 +01:00
$sql = " SELECT rowid, status FROM " . MAIN_DB_PREFIX . " pos_cash_fence WHERE " ;
2021-11-11 16:14:48 +01:00
$sql .= " entity = " . (( int ) $conf -> entity ) . " AND " ;
2021-11-11 16:06:21 +01:00
$sql .= " posnumber = " . (( int ) $_SESSION [ " takeposterminal " ]) . " AND " ;
2021-02-26 21:17:52 +01:00
$sql .= " date_creation > ' " . $db -> idate ( dol_get_first_hour ( dol_now ())) . " ' " ;
2020-03-30 20:05:45 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$obj = $db -> fetch_object ( $resql );
// If there is no cash control from today open it
2021-02-26 21:17:52 +01:00
if ( $obj -> rowid == null ) {
print " ControlCashOpening(); " ;
}
2020-03-30 20:05:45 +02:00
}
}
2019-05-08 18:29:00 +02:00
?>
2018-09-28 13:31:41 +02:00
});
</ script >
2019-11-30 23:03:30 +01:00
< body class = " bodytakepos " style = " overflow: hidden; " >
2019-05-08 18:29:00 +02:00
< ? php
2021-07-08 12:17:32 +02:00
$keyCodeForEnter = getDolGlobalInt ( 'CASHDESK_READER_KEYCODE_FOR_ENTER' . $_SESSION [ 'takeposterminal' ]) > 0 ? getDolGlobalInt ( 'CASHDESK_READER_KEYCODE_FOR_ENTER' . $_SESSION [ 'takeposterminal' ]) : '' ;
2019-05-08 18:29:00 +02:00
?>
2019-01-27 01:28:32 +01:00
< div class = " container " >
2020-01-27 01:31:39 +01:00
< ? php
if ( empty ( $conf -> global -> TAKEPOS_HIDE_HEAD_BAR )) {
2020-01-27 01:52:35 +01:00
?>
2020-01-27 01:31:39 +01:00
< div class = " header " >
< div class = " topnav " >
< div class = " topnav-left " >
2021-12-20 13:39:34 +01:00
< div class = " inline-block valignmiddle " >
< a class = " topnav-terminalhour " onclick = " ModalBox('ModalTerminal'); " >
< span class = " fa fa-cash-register " ></ span >
< span class = " hideonsmartphone " >
< ? php echo $langs -> trans ( " Terminal " ); ?>
</ span >
< ? php echo " " ;
if ( $_SESSION [ " takeposterminal " ] == " " ) {
echo " 1 " ;
} else {
echo $_SESSION [ " takeposterminal " ];
}
echo '<span class="hideonsmartphone"> - ' . dol_print_date ( dol_now (), " day " ) . '</span>' ;
?>
</ a >
< ? php
2022-08-26 17:03:20 +02:00
if ( isModEnabled ( 'multicurrency' )) {
2021-12-20 13:39:34 +01:00
print '<a class="valignmiddle tdoverflowmax100" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>' ;
print '<span class="hideonsmartphone">' . $langs -> trans ( " Currency " ) . '</span>' ;
print '</a>' ;
}
?>
</ div >
<!-- section for customer -->
< div class = " inline-block valignmiddle " id = " customerandsales " ></ div >
<!-- section for shopping carts -->
< div class = " inline-block valignmiddle " id = " shoppingcart " ></ div >
<!-- More info about customer -->
< div class = " inline-block valignmiddle tdoverflowmax150onsmartphone " id = " moreinfo " ></ div >
< ? php
2022-08-26 17:03:20 +02:00
if ( isModEnabled ( 'stock' )) {
2021-12-20 13:39:34 +01:00
?>
<!-- More info about warehouse -->
< div class = " inline-block valignmiddle tdoverflowmax150onsmartphone " id = " infowarehouse " ></ div >
< ? php
}
?>
2020-01-27 01:31:39 +01:00
</ div >
< div class = " topnav-right " >
2020-02-24 19:24:38 +01:00
< div class = " login_block_other " >
2022-04-29 16:02:05 +02:00
< input type = " text " id = " search " name = " search " class = " input-search-takepos " onkeyup = " Search2('<?php echo dol_escape_js( $keyCodeForEnter ); ?>', null); " placeholder = " <?php echo dol_escape_htmltag( $langs->trans ( " Search " )); ?> " autofocus >
2020-01-27 01:31:39 +01:00
< a onclick = " ClearSearch(); " >< span class = " fa fa-backspace " ></ span ></ a >
2021-12-05 15:11:10 +01:00
< a href = " <?php echo DOL_URL_ROOT.'/'; ?> " target = " backoffice " rel = " opener " ><!-- we need rel = " opener " here , we are on same domain and we need to be able to reuse this tab several times -->
< span class = " fas fa-home " ></ span ></ a >
2020-05-17 16:10:29 +02:00
< ? php if ( empty ( $conf -> dol_use_jmobile )) { ?>
2020-12-04 00:58:51 +01:00
< a class = " hideonsmartphone " onclick = " FullScreen(); " >< span class = " fa fa-expand-arrows-alt " ></ span ></ a >
2020-05-17 16:10:29 +02:00
< ? php } ?>
2020-02-24 19:24:38 +01:00
</ div >
< div class = " login_block_user " >
< ? php
2021-12-31 14:33:12 +01:00
print top_menu_user ( 1 );
2020-02-24 19:24:38 +01:00
?>
</ div >
2020-01-27 01:31:39 +01:00
</ div >
</ div >
</ div >
2019-12-09 08:39:11 +01:00
< ? php
2020-01-27 01:31:39 +01:00
}
?>
2020-09-27 11:11:31 +02:00
<!-- Modal terminal box -->
< div id = " ModalTerminal " class = " modal " >
< div class = " modal-content " >
< div class = " modal-header " >
2020-10-03 22:13:32 +02:00
< span class = " close " href = " # " onclick = " document.getElementById('ModalTerminal').style.display = 'none'; " >& times ; </ span >
2020-10-07 15:01:28 +02:00
< h3 >< ? php print $langs -> trans ( " TerminalSelect " ); ?> </h3>
2020-09-27 11:11:31 +02:00
</ div >
< div class = " modal-body " >
2020-10-07 15:01:28 +02:00
< button type = " button " class = " block " onclick = " location.href='index.php?setterminal=1' " >< ? php print $langs -> trans ( " Terminal " ); ?> 1</button>
2020-09-27 11:11:31 +02:00
< ? php
2022-04-08 00:42:39 +02:00
$nbloop = getDolGlobalInt ( 'TAKEPOS_NUM_TERMINALS' );
for ( $i = 2 ; $i <= $nbloop ; $i ++ ) {
2020-09-27 11:35:07 +02:00
print '<button type="button" class="block" onclick="location.href=\'index.php?setterminal=' . $i . '\'">' . $langs -> trans ( " Terminal " ) . ' ' . $i . '</button>' ;
}
2020-09-27 11:11:31 +02:00
?>
</ div >
</ div >
</ div >
2020-10-03 22:13:32 +02:00
<!-- Modal multicurrency box -->
2022-08-26 17:03:20 +02:00
< ? php if ( isModEnabled ( 'multicurrency' )) { ?>
2020-10-03 22:13:32 +02:00
< div id = " ModalCurrency " class = " modal " >
< div class = " modal-content " >
< div class = " modal-header " >
< span class = " close " href = " # " onclick = " document.getElementById('ModalCurrency').style.display = 'none'; " >& times ; </ span >
2020-10-06 09:57:04 +02:00
< h3 >< ? php print $langs -> trans ( " SetMultiCurrencyCode " ); ?> </h3>
2020-10-03 22:13:32 +02:00
</ div >
< div class = " modal-body " >
< ? php
$sql = 'SELECT code FROM ' . MAIN_DB_PREFIX . 'multicurrency' ;
2020-10-04 14:04:44 +02:00
$sql .= " WHERE entity IN (' " . getEntity ( 'multicurrency' ) . " ') " ;
2020-10-03 22:31:55 +02:00
$resql = $db -> query ( $sql );
2021-02-26 21:17:52 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
print '<button type="button" class="block" onclick="location.href=\'index.php?setcurrency=' . $obj -> code . '\'">' . $obj -> code . '</button>' ;
}
2020-10-03 22:31:55 +02:00
}
2020-10-03 22:13:32 +02:00
?>
</ div >
</ div >
</ div >
2020-10-06 09:57:04 +02:00
< ? php } ?>
2020-09-27 11:11:31 +02:00
2020-10-25 20:03:25 +01:00
<!-- Modal terminal Credit Note -->
< div id = " ModalCreditNote " class = " modal " >
< div class = " modal-content " >
< div class = " modal-header " >
< span class = " close " href = " # " onclick = " document.getElementById('ModalCreditNote').style.display = 'none'; " >& times ; </ span >
< h3 >< ? php print $langs -> trans ( " invoiceAvoirWithLines " ); ?> </h3>
</ div >
< div class = " modal-body " >
< button type = " button " class = " block " onclick = " CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none'; " >< ? php print $langs -> trans ( " Yes " ); ?> </button>
< button type = " button " class = " block " onclick = " document.getElementById('ModalCreditNote').style.display = 'none'; " >< ? php print $langs -> trans ( " No " ); ?> </button>
</ div >
</ div >
2021-04-14 00:15:02 +02:00
</ div >
<!-- Modal Note -->
< div id = " ModalNote " class = " modal " >
< div class = " modal-content " >
< div class = " modal-header " >
< span class = " close " href = " # " onclick = " document.getElementById('ModalNote').style.display = 'none'; " >& times ; </ span >
2021-04-14 00:32:49 +02:00
< h3 >< ? php print $langs -> trans ( " Note " ); ?> </h3>
2021-04-14 00:15:02 +02:00
</ div >
< div class = " modal-body " >
< input type = " text " class = " block " id = " textinput " >
< button type = " button " class = " block " onclick = " SetNote(); document.getElementById('ModalNote').style.display = 'none'; " > OK </ button >
</ div >
</ div >
2020-10-25 20:03:25 +01:00
</ div >
2021-02-26 21:17:52 +01:00
< div class = " row1<?php if (empty( $conf->global ->TAKEPOS_HIDE_HEAD_BAR)) {
print 'withhead' ;
} ?> ">
2018-09-28 13:31:41 +02:00
2019-02-02 23:57:38 +01:00
< div id = " poslines " class = " div1 " >
2019-01-27 01:28:32 +01:00
</ 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 >
2019-03-28 18:51:04 +01:00
< button type = " button " class = " calcbutton poscolorblue " onclick = " Edit('c'); " > C </ button >
< button type = " button " class = " calcbutton2 poscolordelete " id = " delete " onclick = " deleteline(); " >< span class = " fa fa-trash " ></ span ></ button >
2019-01-27 01:28:32 +01:00
</ div >
2018-09-28 13:31:41 +02:00
< ? php
2019-03-27 12:40:32 +01:00
2019-02-02 23:57:38 +01:00
// TakePOS setup check
2021-09-07 14:27:31 +02:00
if ( isset ( $_SESSION [ " takeposterminal " ]) && $_SESSION [ " takeposterminal " ]) {
2021-09-07 13:31:09 +02:00
$sql = " SELECT code, libelle FROM " . MAIN_DB_PREFIX . " c_paiement " ;
2021-09-07 14:27:31 +02:00
$sql .= " WHERE entity IN ( " . getEntity ( 'c_paiement' ) . " ) " ;
2021-09-07 13:31:09 +02:00
$sql .= " AND active = 1 " ;
$sql .= " ORDER BY libelle " ;
2021-09-07 14:27:31 +02:00
$resql = $db -> query ( $sql );
2021-09-07 13:31:09 +02:00
$paiementsModes = array ();
2021-09-07 14:27:31 +02:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql ) ) {
2021-09-07 13:31:09 +02:00
$paycode = $obj -> code ;
2021-09-07 14:27:31 +02:00
if ( $paycode == 'LIQ' ) {
2021-09-07 13:31:09 +02:00
$paycode = 'CASH' ;
}
2021-09-07 14:27:31 +02:00
if ( $paycode == 'CHQ' ) {
2021-09-07 13:31:09 +02:00
$paycode = 'CHEQUE' ;
}
2019-03-27 12:40:32 +01:00
2021-09-07 13:31:09 +02:00
$constantforkey = " CASHDESK_ID_BANKACCOUNT_ " . $paycode . $_SESSION [ " takeposterminal " ];
//var_dump($constantforkey.' '.$conf->global->$constantforkey);
2021-09-07 14:27:31 +02:00
if ( ! empty ( $conf -> global -> $constantforkey ) && $conf -> global -> $constantforkey > 0 ) {
array_push ( $paiementsModes , $obj );
2021-09-07 13:31:09 +02:00
}
2021-02-26 21:17:52 +01:00
}
2019-03-15 12:07:33 +01:00
}
2019-10-03 17:11:41 +02:00
2022-08-26 17:03:20 +02:00
if ( empty ( $paiementsModes ) && isModEnabled ( 'banque' )) {
2021-09-07 14:27:31 +02:00
$langs -> load ( 'errors' );
setEventMessages ( $langs -> trans ( " ErrorModuleSetupNotComplete " , $langs -> transnoentitiesnoconv ( " TakePOS " )), null , 'errors' );
setEventMessages ( $langs -> trans ( " ProblemIsInSetupOfTerminal " , $_SESSION [ " takeposterminal " ]), null , 'errors' );
2021-09-07 13:31:09 +02:00
}
2019-02-02 23:57:38 +01:00
}
2021-09-07 13:31:09 +02:00
2019-11-08 15:51:54 +01:00
if ( count ( $maincategories ) == 0 ) {
2021-02-14 22:44:04 +01:00
if ( $conf -> global -> TAKEPOS_ROOT_CATEGORY_ID > 0 ) {
$tmpcategory = new Categorie ( $db );
$tmpcategory -> fetch ( $conf -> global -> TAKEPOS_ROOT_CATEGORY_ID );
setEventMessages ( $langs -> trans ( " TakeposNeedsAtLeastOnSubCategoryIntoParentCategory " , $tmpcategory -> label ), null , 'errors' );
} else {
setEventMessages ( $langs -> trans ( " TakeposNeedsCategories " ), null , 'errors' );
}
2019-02-03 19:15:41 +01:00
}
2018-09-28 13:31:41 +02:00
// User menu and external TakePOS modules
$menus = array ();
2019-11-08 15:51:54 +01:00
$r = 0 ;
2019-04-02 17:36:27 +02:00
2021-02-26 21:17:52 +01:00
if ( empty ( $conf -> global -> TAKEPOS_BAR_RESTAURANT )) {
2020-10-31 14:32:18 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " New " ) . '</div>' , 'action' => 'New();' );
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
// BAR RESTAURANT specific menu
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Place " ) . '</div>' , 'action' => 'Floors();' );
2019-04-02 17:36:27 +02:00
}
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_HIDE_HEAD_BAR )) {
2020-01-27 01:31:39 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="far fa-building paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Customer " ) . '</div>' , 'action' => 'Customer();' );
}
2019-11-08 15:51:54 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-history paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " History " ) . '</div>' , 'action' => 'History();' );
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-cube paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " FreeZone " ) . '</div>' , 'action' => 'FreeZone();' );
2020-03-11 12:30:07 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-percent paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Reduction " ) . '</div>' , 'action' => 'Reduction();' );
2019-11-08 15:51:54 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Payment " ) . '</div>' , 'action' => 'CloseBill();' );
2018-12-07 00:40:00 +01:00
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_DIRECT_PAYMENT' )) {
2020-06-29 09:43:39 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="far fa-money-bill-alt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " DirectPayment " ) . ' <span class="opacitymedium">(' . $langs -> trans ( " Cash " ) . ')</span></div>' , 'action' => 'DirectPayment();' );
2019-08-20 23:44:30 +02:00
}
2021-08-21 22:29:18 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fas fa-cut paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " SplitSale " ) . '</div>' , 'action' => 'Split();' );
2019-03-27 18:00:44 +01:00
// BAR RESTAURANT specific menu
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_BAR_RESTAURANT' )) {
2022-04-08 00:42:39 +02:00
if ( getDolGlobalString ( 'TAKEPOS_ORDER_PRINTERS' )) {
2021-04-28 20:44:22 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-blender-phone paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Order " ) . '</span>' , 'action' => 'TakeposPrintingOrder();' );
2018-12-17 22:43:02 +01:00
}
2020-04-02 22:11:16 +02:00
//Button to print receipt before payment
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_BAR_RESTAURANT' )) {
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " ) {
if ( getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' ) && filter_var ( $conf -> global -> TAKEPOS_PRINT_SERVER , FILTER_VALIDATE_URL ) == true ) {
2021-02-26 21:17:52 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Receipt " ) . '</div>' , 'action' => 'TakeposConnector(placeid);' );
} else {
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Receipt " ) . '</div>' , 'action' => 'TakeposPrinting(placeid);' );
}
2021-07-08 12:17:32 +02:00
} elseif ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " receiptprinter " ) {
2020-04-02 22:11:16 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Receipt " ) . '</div>' , 'action' => 'DolibarrTakeposPrinting(placeid);' );
2019-11-03 00:50:58 +01:00
} else {
2020-01-30 01:48:28 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Receipt " ) . '</div>' , 'action' => 'Print(placeid);' );
2019-11-03 00:50:58 +01:00
}
2018-12-17 22:43:02 +01:00
}
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " && getDolGlobalString ( 'TAKEPOS_ORDER_NOTES' ) == 1 ) {
2021-04-14 00:15:02 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-sticky-note paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " OrderNotes " ) . '</div>' , 'action' => 'TakeposOrderNotes();' );
2019-03-03 12:50:36 +01:00
}
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_SUPPLEMENTS' )) {
2020-10-31 14:32:18 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " ProductSupplements " ) . '</div>' , 'action' => 'LoadProducts(\'supplements\');' );
2019-12-08 23:16:49 +01:00
}
2018-09-28 13:31:41 +02:00
}
2018-12-07 00:40:00 +01:00
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " ) {
2020-10-31 14:32:18 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " DOL_OPEN_DRAWER " ) . '</div>' , 'action' => 'OpenDrawer();' );
2018-11-21 16:54:40 +01:00
}
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " receiptprinter " ) {
2020-10-31 14:32:18 +01:00
$menus [ $r ++ ] = array (
2019-11-03 00:50:58 +01:00
'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " DOL_OPEN_DRAWER " ) . '</div>' ,
'action' => 'DolibarrOpenDrawer();' ,
);
}
2019-01-23 20:59:34 +01:00
2021-02-02 23:09:23 +01:00
$sql = " SELECT rowid, status, entity FROM " . MAIN_DB_PREFIX . " pos_cash_fence WHERE " ;
2021-11-11 16:14:48 +01:00
$sql .= " entity = " . (( int ) $conf -> entity ) . " AND " ;
$sql .= " posnumber = " . (( int ) $_SESSION [ " takeposterminal " ]) . " AND " ;
2021-02-03 23:18:44 +01:00
$sql .= " date_creation > ' " . $db -> idate ( dol_get_first_hour ( dol_now ())) . " ' " ;
2021-11-11 18:30:17 +01:00
2020-03-30 20:05:45 +02:00
$resql = $db -> query ( $sql );
2021-02-26 21:17:52 +01:00
if ( $resql ) {
2020-03-30 20:05:45 +02:00
$num = $db -> num_rows ( $resql );
2021-02-26 21:17:52 +01:00
if ( $num ) {
2020-03-30 20:05:45 +02:00
$obj = $db -> fetch_object ( $resql );
$menus [ $r ++ ] = array ( 'title' => '<span class="fas fa-file-invoice-dollar paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " CashReport " ) . '</div>' , 'action' => 'CashReport(' . $obj -> rowid . ');' );
2021-02-26 21:17:52 +01:00
if ( $obj -> status == 0 ) {
$menus [ $r ++ ] = array ( 'title' => '<span class="fas fa-cash-register paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " CloseCashFence " ) . '</div>' , 'action' => 'CloseCashFence(' . $obj -> rowid . ');' );
}
2020-03-30 20:05:45 +02:00
}
}
2019-01-23 20:59:34 +01:00
$hookmanager -> initHooks ( array ( 'takeposfrontend' ));
2021-10-27 15:59:27 +02:00
$parameters = array ( 'menus' => $menus );
2021-10-27 17:00:46 +02:00
$reshook = $hookmanager -> executeHooks ( 'ActionButtons' , $parameters );
2021-10-27 15:59:27 +02:00
if ( $reshook == 0 ) { //add buttons
2021-10-27 17:00:46 +02:00
if ( is_array ( $hookmanager -> resArray ) ) {
foreach ( $hookmanager -> resArray as $resArray ) {
foreach ( $resArray as $butmenu ) {
$menus [ $r ++ ] = $butmenu ;
}
}
2021-10-27 17:44:07 +02:00
} elseif ( $reshook == 1 ) {
2021-10-27 17:00:46 +02:00
$r = 0 ; //replace buttons
if ( is_array ( $hookmanager -> resArray ) ) {
foreach ( $hookmanager -> resArray as $resArray ) {
foreach ( $resArray as $butmenu ) {
$menus [ $r ++ ] = $butmenu ;
}
}
}
}
2019-02-03 14:29:45 +01:00
}
2019-01-23 20:59:34 +01:00
2021-02-26 21:17:52 +01:00
if ( $r % 3 == 2 ) {
$menus [ $r ++ ] = array ( 'title' => '' , 'style' => 'visibility: hidden;' );
}
2019-03-28 18:51:04 +01:00
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_HIDE_HEAD_BAR )) {
2021-12-31 14:33:12 +01:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-sign-out-alt paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " Logout " ) . '</div>' , 'action' => 'window.location.href=\'' . DOL_URL_ROOT . '/user/logout.php?token=' . newToken () . '\';' );
2020-01-27 01:31:39 +01:00
}
2019-03-28 18:51:04 +01:00
2021-07-08 12:17:32 +02:00
if ( ! empty ( $conf -> global -> TAKEPOS_WEIGHING_SCALE )) {
2020-09-13 21:12:14 +02:00
$menus [ $r ++ ] = array ( 'title' => '<span class="fa fa-balance-scale paddingrightonly"></span><div class="trunc">' . $langs -> trans ( " WeighingScale " ) . '</div>' , 'action' => 'WeighingScale();' );
}
2018-09-28 13:31:41 +02:00
?>
2019-03-28 18:51:04 +01:00
<!-- Show buttons -->
2019-01-27 01:28:32 +01:00
< div class = " div3 " >
2019-03-28 18:51:04 +01:00
< ? php
2020-10-31 14:32:18 +01:00
$i = 0 ;
2021-02-26 21:17:52 +01:00
foreach ( $menus as $menu ) {
2020-10-31 14:32:18 +01:00
$i ++ ;
2021-02-26 21:17:52 +01:00
if ( count ( $menus ) > 12 and $i == 12 ) {
2021-07-08 12:17:32 +02:00
echo '<button style="' . ( empty ( $menu [ 'style' ]) ? '' : $menu [ 'style' ]) . '" 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="' . ( empty ( $menu [ 'action' ]) ? '' : $menu [ 'action' ]) . '">' . $menu [ 'title' ] . '</button>' ;
2021-02-26 21:17:52 +01:00
} elseif ( $i > 12 ) {
2021-07-08 12:17:32 +02:00
echo '<button style="display: none;" type="button" id="action' . $i . '" class="actionbutton" onclick="' . ( empty ( $menu [ 'action' ]) ? '' : $menu [ 'action' ]) . '">' . $menu [ 'title' ] . '</button>' ;
2021-02-26 21:17:52 +01:00
} else {
2021-07-08 12:17:32 +02:00
echo '<button style="' . ( empty ( $menu [ 'style' ]) ? '' : $menu [ 'style' ]) . '" type="button" id="action' . $i . '" class="actionbutton" onclick="' . ( empty ( $menu [ 'action' ]) ? '' : $menu [ 'action' ]) . '">' . $menu [ 'title' ] . '</button>' ;
2021-02-26 21:17:52 +01:00
}
2020-10-31 14:32:18 +01:00
}
2019-03-15 00:49:44 +01:00
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_HIDE_HEAD_BAR )) {
2020-01-27 01:31:39 +01:00
print '<!-- Show the search input text -->' . " \n " ;
print '<div class="margintoponly">' ;
2022-04-29 16:02:05 +02:00
print '<input type="text" id="search" class="input-search-takepos" name="search" onkeyup="Search2(\'' . dol_escape_js ( $keyCodeForEnter ) . '\', null);" style="width: 80%; width:calc(100% - 51px); font-size: 150%;" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '" autofocus> ' ;
2020-01-27 01:31:39 +01:00
print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">' . img_picto ( '' , 'searchclear' ) . '</a>' ;
print '</div>' ;
}
2020-10-31 14:32:18 +01:00
?>
2019-01-27 01:28:32 +01:00
</ div >
</ div >
2019-03-15 00:49:44 +01:00
2021-02-26 21:17:52 +01:00
< div class = " row2<?php if (empty( $conf->global ->TAKEPOS_HIDE_HEAD_BAR)) {
print 'withhead' ;
} ?> ">
2019-03-28 18:51:04 +01:00
<!-- Show categories -->
2021-12-01 10:26:24 +01:00
< ? php
2022-04-08 00:42:39 +02:00
if ( getDolGlobalInt ( 'TAKEPOS_HIDE_CATEGORIES' ) == 1 ) {
2021-12-01 10:53:28 +01:00
print '<div class="div4" style= "display: none;">' ;
} else {
print '<div class="div4">' ;
}
2022-04-08 00:42:39 +02:00
$count = 0 ;
2021-12-01 10:53:28 +01:00
while ( $count < $MAXCATEG ) {
?>
2021-02-26 21:17:52 +01:00
< div class = " wrapper " < ? php if ( $count == ( $MAXCATEG - 2 )) {
echo 'onclick="MoreCategories(\'less\');"' ;
} elseif ( $count == ( $MAXCATEG - 1 )) {
echo 'onclick="MoreCategories(\'more\');"' ;
} else {
echo 'onclick="LoadProducts(' . $count . ');"' ;
} ?> id="catdiv<?php echo $count; ?>">
2019-03-29 11:45:40 +01:00
< ? php
2019-11-08 15:51:54 +01:00
if ( $count == ( $MAXCATEG - 2 )) {
2020-10-31 14:32:18 +01:00
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="catimg'.$count.'" />';
2022-04-29 10:00:25 +02:00
echo '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>' ;
2020-05-21 15:05:19 +02:00
} elseif ( $count == ( $MAXCATEG - 1 )) {
2020-10-31 14:32:18 +01:00
//echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="catimg'.$count.'" />';
2022-04-29 10:00:25 +02:00
echo '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-07-08 12:17:32 +02:00
if ( ! getDolGlobalString ( 'TAKEPOS_HIDE_CATEGORY_IMAGES' )) {
2021-02-26 21:17:52 +01:00
echo '<img class="imgwrapper" height="100%" id="catimg' . $count . '" />' ;
}
2019-03-29 11:45:40 +01:00
}
?>
2019-11-08 15:51:54 +01:00
< ? php if ( $count != ( $MAXCATEG - 2 ) && $count != ( $MAXCATEG - 1 )) { ?>
< div class = " description " id = " catdivdesc<?php echo $count ; ?> " >
< div class = " description_content " id = " catdesc<?php echo $count ; ?> " ></ div >
2019-01-27 01:28:32 +01:00
</ div >
2019-03-29 11:45:40 +01:00
< ? php } ?>
2019-12-04 20:15:48 +01:00
< div class = " catwatermark " id = 'catwatermark<?php echo $count; ?>' >...</ div >
2019-01-27 01:28:32 +01:00
</ div >
2021-12-01 10:53:28 +01:00
< ? php
$count ++ ;
}
?>
2019-01-27 01:28:32 +01:00
</ div >
2018-09-28 13:31:41 +02:00
2021-02-26 21:17:52 +01:00
<!-- Show product -->
2022-04-08 00:42:39 +02:00
< div class = " div5 " < ? php if ( getDolGlobalInt ( 'TAKEPOS_HIDE_CATEGORIES' ) == 1 ) {
2021-12-01 10:26:24 +01:00
print ' style="width:100%;"' ;
2021-12-01 10:53:28 +01:00
} ?> >
2021-02-26 21:17:52 +01:00
< ? php
2020-10-31 14:32:18 +01:00
$count = 0 ;
2021-02-26 21:17:52 +01:00
while ( $count < $MAXPRODUCT ) {
2021-12-01 10:26:24 +01:00
print '<div class="wrapper2" id="prodiv' . $count . '" ' ;
2020-10-31 14:32:18 +01:00
?>
2021-12-01 10:26:24 +01:00
< ? php if ( $count == ( $MAXPRODUCT - 2 )) {
2021-02-26 21:17:52 +01:00
?> onclick="MoreProducts('less');" <?php
2021-12-01 10:53:28 +01:00
} if ( $count == ( $MAXPRODUCT - 1 )) {
?> onclick="MoreProducts('more');" <?php
} else {
echo 'onclick="ClickProduct(' . $count . ');"' ;
} ?> >
2021-02-26 21:17:52 +01:00
< ? php
2020-10-31 14:32:18 +01:00
if ( $count == ( $MAXPRODUCT - 2 )) {
//echo '<img class="imgwrapper" src="img/arrow-prev-top.png" height="100%" id="proimg'.$count.'" />';
2022-04-29 10:00:25 +02:00
print '<span class="fa fa-chevron-left centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>' ;
2020-10-31 14:32:18 +01:00
} elseif ( $count == ( $MAXPRODUCT - 1 )) {
//echo '<img class="imgwrapper" src="img/arrow-next-top.png" height="100%" id="proimg'.$count.'" />';
2022-04-29 10:00:25 +02:00
print '<span class="fa fa-chevron-right centerinmiddle" style="font-size: 5em; cursor: pointer;"></span>' ;
2020-10-31 14:32:18 +01:00
} else {
2021-07-08 12:17:32 +02:00
if ( getDolGlobalString ( 'TAKEPOS_HIDE_PRODUCT_IMAGES' )) {
2021-02-26 21:17:52 +01:00
echo '<button type="button" id="probutton' . $count . '" class="productbutton" style="display: none;"></button>' ;
} else {
2020-09-16 06:54:01 +02:00
print '<div class="" id="proprice' . $count . '"></div>' ;
print '<img class="imgwrapper" height="100%" title="" id="proimg' . $count . '">' ;
}
2020-10-31 14:32:18 +01:00
}
?>
2021-07-08 12:17:32 +02:00
< ? php if ( $count != ( $MAXPRODUCT - 2 ) && $count != ( $MAXPRODUCT - 1 ) && ! getDolGlobalString ( 'TAKEPOS_HIDE_PRODUCT_IMAGES' )) { ?>
2021-02-26 21:17:52 +01:00
< div class = " description " id = " prodivdesc<?php echo $count ; ?> " >
< div class = " description_content " id = " prodesc<?php echo $count ; ?> " ></ div >
</ div >
< ? php } ?>
< div class = " catwatermark " id = 'prowatermark<?php echo $count; ?>' >...</ div >
</ div >
< ? php
2020-10-31 14:32:18 +01:00
$count ++ ;
}
?>
2022-04-29 10:00:25 +02:00
< input type = " hidden " id = " search_start_less " value = " 0 " >
< input type = " hidden " id = " search_start_more " value = " 0 " >
< input type = " hidden " id = " search_pagination " value = " " >
2019-01-27 01:28:32 +01:00
</ div >
</ div >
2018-09-28 13:31:41 +02:00
</ div >
</ body >
< ? php
llxFooter ();
$db -> close ();