beautify code
This commit is contained in:
parent
ab0750cbbf
commit
b9ca32a7f2
@ -1,232 +1,290 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
|
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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('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('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
|
||||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','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');
|
|
||||||
|
|
||||||
require '../main.inc.php'; // Load $user and permissions
|
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
||||||
|
|
||||||
$langs->loadLangs(array("bills", "cashdesk"));
|
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
||||||
|
|
||||||
$id = GETPOST('id','int');
|
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
||||||
$action = GETPOST('action','alpha');
|
|
||||||
$idproduct = GETPOST('idproduct','int');
|
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
||||||
$place = GETPOST('place','int');
|
|
||||||
|
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
||||||
|
require '../main.inc.php';
|
||||||
|
|
||||||
|
// Load $user and permissions
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
||||||
|
|
||||||
|
$langs->loadLangs(array(
|
||||||
|
"bills",
|
||||||
|
"cashdesk"
|
||||||
|
));
|
||||||
|
$id = GETPOST('id', 'int');
|
||||||
|
$action = GETPOST('action', 'alpha');
|
||||||
|
$idproduct = GETPOST('idproduct', 'int');
|
||||||
|
$place = GETPOST('place', 'int');
|
||||||
$number = GETPOST('number');
|
$number = GETPOST('number');
|
||||||
$idline = GETPOST('idline');
|
$idline = GETPOST('idline');
|
||||||
$desc = GETPOST('desc','alpha');
|
$desc = GETPOST('desc', 'alpha');
|
||||||
$pay = GETPOST('pay');
|
$pay = GETPOST('pay');
|
||||||
|
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facture where facnumber='(PROV-POS-" . $place . ")'";
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where facnumber='(PROV-POS-".$place.")'";
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
$row = $db->fetch_array ($resql);
|
$row = $db->fetch_array($resql);
|
||||||
$placeid=$row[0];
|
$placeid = $row[0];
|
||||||
if (! $placeid) $placeid=0; // not necesary
|
|
||||||
else{
|
if (!$placeid) $placeid = 0; // not necesary
|
||||||
|
else
|
||||||
|
{
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'valid' && $user->rights->facture->creer){
|
if ($action == 'valid' && $user->rights->facture->creer)
|
||||||
if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
|
{
|
||||||
else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
|
if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
|
||||||
else if ($pay=="cheque") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
|
else
|
||||||
$now=dol_now();
|
if ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB;
|
||||||
|
else
|
||||||
|
if ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
|
||||||
|
$now = dol_now();
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE);
|
if (!empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE);
|
||||||
else $invoice->validate($user);
|
else $invoice->validate($user);
|
||||||
|
|
||||||
// Add the payment
|
// Add the payment
|
||||||
$payment=new Paiement($db);
|
|
||||||
$payment->datepaye=$now;
|
$payment = new Paiement($db);
|
||||||
$payment->bank_account=$bankaccount;
|
$payment->datepaye = $now;
|
||||||
$payment->amounts[$invoice->id]=$invoice->total_ttc;
|
$payment->bank_account = $bankaccount;
|
||||||
if ($pay=="cash") $payment->paiementid=4;
|
$payment->amounts[$invoice->id] = $invoice->total_ttc;
|
||||||
else if ($pay=="card") $payment->paiementid=6;
|
if ($pay == "cash") $payment->paiementid = 4;
|
||||||
else if ($pay=="cheque") $payment->paiementid=7;
|
else
|
||||||
$payment->num_paiement=$invoice->facnumber;
|
if ($pay == "card") $payment->paiementid = 6;
|
||||||
|
else
|
||||||
|
if ($pay == "cheque") $payment->paiementid = 7;
|
||||||
|
$payment->num_paiement = $invoice->facnumber;
|
||||||
$payment->create($user);
|
$payment->create($user);
|
||||||
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
||||||
$invoice->set_paid($user);
|
$invoice->set_paid($user);
|
||||||
}
|
|
||||||
|
|
||||||
if (($action=="addline" || $action=="freezone") and $placeid==0)
|
|
||||||
{
|
|
||||||
// $place is id of POS, $placeid is id of invoice
|
|
||||||
if ($placeid==0) {
|
|
||||||
$invoice = new Facture($db);
|
|
||||||
$invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY;
|
|
||||||
$invoice->date=dol_now();
|
|
||||||
$invoice->ref="(PROV-POS)";
|
|
||||||
$invoice->module_source = 'takepos';
|
|
||||||
$invoice->pos_source = (string) (empty($place)?'0':$place);
|
|
||||||
|
|
||||||
$placeid=$invoice->create($user);
|
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid;
|
|
||||||
$db->query($sql);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($action=="addline"){
|
if (($action == "addline" || $action == "freezone") and $placeid == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
// $place is id of POS, $placeid is id of invoice
|
||||||
|
|
||||||
|
if ($placeid == 0)
|
||||||
|
{
|
||||||
|
$invoice = new Facture($db);
|
||||||
|
$invoice->socid = $conf->global->CASHDESK_ID_THIRDPARTY;
|
||||||
|
$invoice->date = dol_now();
|
||||||
|
$invoice->ref = "(PROV-POS)";
|
||||||
|
$invoice->module_source = 'takepos';
|
||||||
|
$invoice->pos_source = (string)(empty($place) ? '0' : $place);
|
||||||
|
$placeid = $invoice->create($user);
|
||||||
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "facture set facnumber='(PROV-POS-" . $place . ")' where rowid=" . $placeid;
|
||||||
|
$db->query($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == "addline")
|
||||||
|
{
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$prod->fetch($idproduct);
|
$prod->fetch($idproduct);
|
||||||
$invoice->addline($prod->description, $prod->price, 1, $prod->tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $prod->price_base_type, $prod->price_ttc, $prod->type, - 1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
|
$invoice->addline($prod->description, $prod->price, 1, $prod->tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $prod->price_base_type, $prod->price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="freezone"){
|
if ($action == "freezone")
|
||||||
$invoice->addline($desc, $number, 1, $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS, 0, 0, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, - 1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
|
{
|
||||||
|
$invoice->addline($desc, $number, 1, $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS, 0, 0, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="deleteline"){
|
if ($action == "deleteline")
|
||||||
if ($idline>0 and $placeid>0){ //If exist invoice and line, to avoid errors if deleted from other device or no line selected
|
{
|
||||||
$invoice->deleteline($idline);
|
if ($idline > 0 and $placeid > 0)
|
||||||
$invoice->fetch($placeid);
|
{ //If exist invoice and line, to avoid errors if deleted from other device or no line selected
|
||||||
}
|
$invoice->deleteline($idline);
|
||||||
else if ($placeid>0){ //If exist invoice, but no line selected, proced to delete last line
|
$invoice->fetch($placeid);
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='$placeid' order by rowid DESC";
|
}
|
||||||
$resql = $db->query($sql);
|
else
|
||||||
$row = $db->fetch_array ($resql);
|
if ($placeid > 0)
|
||||||
$deletelineid=$row[0];
|
{ //If exist invoice, but no line selected, proced to delete last line
|
||||||
$invoice->deleteline($deletelineid);
|
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='$placeid' order by rowid DESC";
|
||||||
$invoice->fetch($placeid);
|
$resql = $db->query($sql);
|
||||||
}
|
$row = $db->fetch_array($resql);
|
||||||
}
|
$deletelineid = $row[0];
|
||||||
|
$invoice->deleteline($deletelineid);
|
||||||
|
$invoice->fetch($placeid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == "updateqty")
|
||||||
|
{
|
||||||
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
|
if ($line->id == $idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action=="updateqty"){
|
|
||||||
foreach ($invoice->lines as $line){
|
|
||||||
if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent,
|
|
||||||
$line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type,
|
|
||||||
$line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent,
|
|
||||||
$line->fk_unit);
|
|
||||||
}
|
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == "updateprice")
|
||||||
|
{
|
||||||
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
|
if ($line->id == $idline) $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action=="updateprice"){
|
|
||||||
foreach ($invoice->lines as $line){
|
|
||||||
if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent,
|
|
||||||
$line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type,
|
|
||||||
$line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent,
|
|
||||||
$line->fk_unit);
|
|
||||||
}
|
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == "updatereduction")
|
||||||
|
{
|
||||||
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
|
if ($line->id == $idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action=="updatereduction"){
|
|
||||||
foreach ($invoice->lines as $line){
|
|
||||||
if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number,
|
|
||||||
$line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type,
|
|
||||||
$line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent,
|
|
||||||
$line->fk_unit);
|
|
||||||
}
|
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="order" and $placeid!=0){
|
if ($action == "order" and $placeid != 0)
|
||||||
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
$headerorder='<html><br><b>'.$langs->trans('Place').' '.$place.'<br><table width="65%"><thead><tr><th align="left">'.$langs->trans("Label").'</th><th align="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
|
|
||||||
$footerorder='</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
|
$headerorder = '<html><br /><b>' . $langs->trans('Place') . ' ' . $place . '<br /><table width="65%"><thead><tr><th align="left">' . $langs->trans("Label") . '</th><th align="right">' . $langs->trans("Qty") . '</th></tr></thead><tbody>';
|
||||||
$order_receipt_printer1="";
|
$footerorder = '</tbody></table>' . dol_print_date(dol_now() , 'dayhour') . '<br /></html>';
|
||||||
$order_receipt_printer2="";
|
$order_receipt_printer1 = "";
|
||||||
$catsprinter1 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
|
$order_receipt_printer2 = "";
|
||||||
$catsprinter2 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
|
$catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
|
||||||
foreach ($invoice->lines as $line){
|
$catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
|
||||||
if ($line->special_code=="3") continue;
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
|
if ($line->special_code == "3") continue;
|
||||||
$c = new Categorie($db);
|
$c = new Categorie($db);
|
||||||
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
||||||
$result = array_intersect($catsprinter1, $existing);
|
$result = array_intersect($catsprinter1, $existing);
|
||||||
$count=count($result);
|
$count = count($result);
|
||||||
if ($count>0){
|
if ($count > 0)
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid";
|
{
|
||||||
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
$order_receipt_printer1.='<tr>'.$line->product_label.'<td align="right">'.$line->qty.'</td></tr>';
|
$order_receipt_printer1.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
foreach ($invoice->lines as $line){
|
foreach($invoice->lines as $line)
|
||||||
if ($line->special_code=="3") continue;
|
{
|
||||||
|
if ($line->special_code == "3") continue;
|
||||||
$c = new Categorie($db);
|
$c = new Categorie($db);
|
||||||
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
||||||
$result = array_intersect($catsprinter2, $existing);
|
$result = array_intersect($catsprinter2, $existing);
|
||||||
$count=count($result);
|
$count = count($result);
|
||||||
if ($count>0){
|
if ($count > 0)
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid";
|
{
|
||||||
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
$order_receipt_printer2.='<tr>'.$line->product_label.'<td align="right">'.$line->qty.'</td></tr>';
|
$order_receipt_printer2.= '<tr>' . $line->product_label . '<td align="right">' . $line->qty . '</td></tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//temporary ticket feature
|
// temporary ticket feature
|
||||||
|
|
||||||
if ($action=="temp" and $placeid!=0){
|
if ($action == "temp" and $placeid != 0)
|
||||||
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
// issues with special characters with jPosBoxprinting ->javascript, StringCleanCharts() temporarily fix them until to find a more elegant solution.
|
// issues with special characters with jPosBoxprinting ->javascript, StringCleanCharts() temporarily fix them until to find a more elegant solution.
|
||||||
|
|
||||||
function StringCleanCharts($text)
|
function StringCleanCharts($text)
|
||||||
{
|
{
|
||||||
$utf8 = array('/[áàâãªä]/u'=>'a','/[ÁÀÂÃÄ]/u'=>'A','/[ÍÌÎÏ]/u'=>'I','/[íìîï]/u'=>'i','/[éèêë]/u'=>'e','/[ÉÈÊË]/u'=>'E','/[óòôõºö]/u'=>'o','/[ÓÒÔÕÖ]/u'=>'O','/[úùûü]/u'=>'u','/[ÚÙÛÜ]/u'=>'U','/ç/'=>'c','/Ç/' =>'C','/ñ/'=>'n','/Ñ/'=>'N','/–/'=>'-','/[’‘‹›‚\']/u'=>' ','/[“”«»„]/u'=>' ','/ /'=>' ',);
|
$utf8 = array(
|
||||||
return preg_replace(array_keys($utf8), array_values($utf8), $text);
|
'/[áàâãªä]/u' => 'a',
|
||||||
}
|
'/[ÁÀÂÃÄ]/u' => 'A',
|
||||||
|
'/[ÍÌÎÏ]/u' => 'I',
|
||||||
$mysocname=StringCleanCharts($mysoc->name);
|
'/[íìîï]/u' => 'i',
|
||||||
$mysocaddress=StringCleanCharts($mysoc->address);
|
'/[éèêë]/u' => 'e',
|
||||||
$mysoctown=StringCleanCharts($mysoc->town);
|
'/[ÉÈÊË]/u' => 'E',
|
||||||
$mysoczip=StringCleanCharts($mysoc->zip);
|
'/[óòôõºö]/u' => 'o',
|
||||||
$mysocphone=StringCleanCharts($mysoc->phone);
|
'/[ÓÒÔÕÖ]/u' => 'O',
|
||||||
$mysocurl=StringCleanCharts($mysoc->url);
|
'/[úùûü]/u' => 'u',
|
||||||
$header_soc='<html><center><font size="4"><b>'.$mysocname.'</b><br>'.$mysocaddress.'<br>'.$mysoczip.' '.$mysoctown.'</font></center><br>'.$langs->trans("Phone").': '.$mysocphone.'<br>'.$mysocurl;
|
'/[ÚÙÛÜ]/u' => 'U',
|
||||||
$header_ticket='<br><br>'.$langs->trans("Temporary ticket").'<br>'.$langs->trans("date").':<br>'.dol_print_date(dol_now(), 'dayhour').'<br>'.$langs->trans('Place').' '.$place.'<br><br><br><div width="100%" style="border-top-style: double;"></div>';
|
'/ç/' => 'c',
|
||||||
$body_ticket='<table width="100%"><thead><tr><th align="left">'.$langs->trans("Label").'</th><th align="left">'.$langs->trans("Qty").'</th><th align="left">'.$langs->trans("Price").'</th><th align="left">'.$langs->trans("TotalTTC").'</th></tr></thead>';
|
'/Ç/' => 'C',
|
||||||
$footer_ticket='<br><br>'.$langs->trans("Cashier").': '.$user->firstname.'<br><center>'.$langs->trans("Thanks for your coming !").'</center></html>';
|
'/ñ/' => 'n',
|
||||||
$ticket_printer1="";
|
'/Ñ/' => 'N',
|
||||||
$catsprinter1 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
|
'/–/' => '-',
|
||||||
foreach ($invoice->lines as $line){
|
'/[’‘‹›‚\']/u' => ' ',
|
||||||
if ($line->special_code=="3") continue;
|
'/[“”«»„]/u' => ' ',
|
||||||
|
'/ /' => ' ',
|
||||||
|
);
|
||||||
|
return preg_replace(array_keys($utf8) , array_values($utf8) , $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mysocname = StringCleanCharts($mysoc->name);
|
||||||
|
$mysocaddress = StringCleanCharts($mysoc->address);
|
||||||
|
$mysoctown = StringCleanCharts($mysoc->town);
|
||||||
|
$mysoczip = StringCleanCharts($mysoc->zip);
|
||||||
|
$mysocphone = StringCleanCharts($mysoc->phone);
|
||||||
|
$mysocurl = StringCleanCharts($mysoc->url);
|
||||||
|
$header_soc = '<html><center><font size="4"><b>' . $mysocname . '</b><br />' . $mysocaddress . '<br />' . $mysoczip . ' ' . $mysoctown . '</font></center><br />' . $langs->trans("Phone") . ': ' . $mysocphone . '<br />' . $mysocurl;
|
||||||
|
$header_ticket = '<br /><br />' . $langs->trans("Temporary ticket") . '<br />' . $langs->trans("date") . ':<br />' . dol_print_date(dol_now() , 'dayhour') . '<br />' . $langs->trans('Place') . ' ' . $place . '<br /><br /><br /><div width="100%" style="border-top-style: double;"></div>';
|
||||||
|
$body_ticket = '<table width="100%"><thead><tr><th align="left">' . $langs->trans("Label") . '</th><th align="left">' . $langs->trans("Qty") . '</th><th align="left">' . $langs->trans("Price") . '</th><th align="left">' . $langs->trans("TotalTTC") . '</th></tr></thead>';
|
||||||
|
$footer_ticket = '<br /><br />' . $langs->trans("Cashier") . ': ' . $user->firstname . '<br /><center>' . $langs->trans("Thanks for your coming !") . '</center></html>';
|
||||||
|
$ticket_printer1 = "";
|
||||||
|
$catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
|
||||||
|
foreach($invoice->lines as $line)
|
||||||
|
{
|
||||||
|
if ($line->special_code == "3") continue;
|
||||||
$c = new Categorie($db);
|
$c = new Categorie($db);
|
||||||
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
|
||||||
$result = array_intersect($catsprinter1, $existing);
|
$result = array_intersect($catsprinter1, $existing);
|
||||||
$count=count($result);
|
$count = count($result);
|
||||||
if ($count>0){
|
if ($count > 0)
|
||||||
$sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid";
|
{
|
||||||
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "facturedet set special_code='3' where rowid=$line->rowid";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
$ticket_printer1.='<tbody><tr><td align="left">'.$line->product_label.'</td><td align="left">'.$line->qty.'</td><td align="left">'.$line->total_ttc/$line->qty.'</td><td align="left">'.$line->total_ttc.'</td></tr></tbody>';
|
$ticket_printer1.= '<tbody><tr><td align="left">' . $line->product_label . '</td><td align="left">' . $line->qty . '</td><td align="left">' . $line->total_ttc / $line->qty . '</td><td align="left">' . $line->total_ttc . '</td></tr></tbody>';
|
||||||
$ticket_total='</table><div width="100%" style="border-top-style: double;"></div><table align="right"><tr><th>'.$langs->trans("TotalHT").': '.price($invoice->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalVAT").': '.price($invoice->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalTTC").': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr></tbody></table>';
|
$ticket_total = '</table><div width="100%" style="border-top-style: double;"></div><table align="right"><tr><th>' . $langs->trans("TotalHT") . ': ' . price($invoice->total_ht, 1, '', 1, -1, -1, $conf->currency) . '</th></tr><tr><th>' . $langs->trans("TotalVAT") . ': ' . price($invoice->total_tva, 1, '', 1, -1, -1, $conf->currency) . '</th></tr><tr><th>' . $langs->trans("TotalTTC") . ': ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '</th></tr></tbody></table>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.selected {
|
.selected {
|
||||||
@ -244,32 +302,44 @@ $(document).ready(function(){
|
|||||||
$('table tbody tr').removeClass("selected");
|
$('table tbody tr').removeClass("selected");
|
||||||
$(this).addClass("selected");
|
$(this).addClass("selected");
|
||||||
if (selectedline==this.id) return; // If is already selected
|
if (selectedline==this.id) return; // If is already selected
|
||||||
else selectedline=this.id;
|
else selectedline=this.id;
|
||||||
selectedtext=$('#'+selectedline).find("td:first").html();
|
selectedtext=$('#'+selectedline).find("td:first").html();
|
||||||
});
|
});
|
||||||
<?php if ($action=="order" and $order_receipt_printer1!=""){
|
<?php
|
||||||
?>
|
|
||||||
|
if ($action == "order" and $order_receipt_printer1 != "")
|
||||||
|
{
|
||||||
|
?>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
|
url: 'http://<?php
|
||||||
data: '<?php print $headerorder.$order_receipt_printer1.$footerorder; ?>'
|
print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
|
||||||
|
data: '<?php
|
||||||
|
print $headerorder . $order_receipt_printer1 . $footerorder; ?>'
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($action=="order" and $order_receipt_printer2!=""){
|
|
||||||
?>
|
if ($action == "order" and $order_receipt_printer2 != "")
|
||||||
|
{
|
||||||
|
?>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print2',
|
url: 'http://<?php
|
||||||
data: '<?php print $headerorder.$order_receipt_printer2.$footerorder; ?>'
|
print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
|
||||||
|
data: '<?php
|
||||||
|
print $headerorder . $order_receipt_printer2 . $footerorder; ?>'
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($action=="search"){
|
|
||||||
?>
|
if ($action == "search")
|
||||||
|
{
|
||||||
|
?>
|
||||||
$('#search').focus();
|
$('#search').focus();
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -278,29 +348,37 @@ $(document).ready(function(){
|
|||||||
$('table tbody tr').removeClass("selected");
|
$('table tbody tr').removeClass("selected");
|
||||||
$(this).addClass("selected");
|
$(this).addClass("selected");
|
||||||
if (selectedline==this.id) return; // If is already selected
|
if (selectedline==this.id) return; // If is already selected
|
||||||
else selectedline=this.id;
|
else selectedline=this.id;
|
||||||
selectedtext=$('#'+selectedline).find("td:first").html();
|
selectedtext=$('#'+selectedline).find("td:first").html();
|
||||||
});
|
});
|
||||||
<?php if ($action=="temp" and $ticket_printer1!=""){
|
<?php
|
||||||
?>
|
|
||||||
|
if ($action == "temp" and $ticket_printer1 != "")
|
||||||
|
{
|
||||||
|
?>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
|
url: 'http://<?php
|
||||||
data: '<?php print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
|
print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
|
||||||
|
data: '<?php
|
||||||
|
print $header_soc . $header_ticket . $body_ticket . $ticket_printer1 . $ticket_total . $footer_ticket; ?>'
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="search"){
|
if ($action == "search")
|
||||||
?>
|
{
|
||||||
|
?>
|
||||||
$('#search').focus();
|
$('#search').focus();
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
});
|
});
|
||||||
|
|
||||||
function Print(id){
|
function Print(id){
|
||||||
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintTicket");?>"});
|
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php
|
||||||
|
echo $langs->trans("PrintTicket"); ?>"});
|
||||||
}
|
}
|
||||||
|
|
||||||
function TakeposPrinting(id){
|
function TakeposPrinting(id){
|
||||||
@ -309,7 +387,8 @@ function TakeposPrinting(id){
|
|||||||
receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
|
receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
|
url: 'http://<?php
|
||||||
|
print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
|
||||||
data: receipt
|
data: receipt
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -319,41 +398,53 @@ function TakeposPrinting(id){
|
|||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||||
print '<tr class="liste_titre nodrag nodrop">';
|
print '<tr class="liste_titre nodrag nodrop">';
|
||||||
print '<td class="linecoldescription">'.$langs->trans('Description').'</td>';
|
print '<td class="linecoldescription">' . $langs->trans('Description') . '</td>';
|
||||||
print '<td class="linecolqty" align="right">'.$langs->trans('Qty').'</td>';
|
print '<td class="linecolqty" align="right">' . $langs->trans('Qty') . '</td>';
|
||||||
print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>';
|
print '<td class="linecolht" align="right">' . $langs->trans('TotalHTShort') . '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
if ($placeid>0) foreach ($invoice->lines as $line)
|
|
||||||
{
|
|
||||||
print '<tr class="drag drop oddeven';
|
|
||||||
if ($line->special_code=="3") print ' order';
|
|
||||||
print '" id="'.$line->rowid.'">';
|
|
||||||
print '<td>'.$line->product_label.$line->desc.'</td>';
|
|
||||||
print '<td align="right">'.$line->qty.'</td>';
|
|
||||||
print '<td align="right">'.price($line->total_ttc).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
print '</table>';
|
|
||||||
print '<p style="font-size:120%;" align="right"><b>'.$langs->trans('TotalTTC');
|
|
||||||
if($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place;
|
|
||||||
print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' </b></p>';
|
|
||||||
|
|
||||||
//if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY){
|
if ($placeid > 0)
|
||||||
$soc = new Societe($db);
|
foreach($invoice->lines as $line)
|
||||||
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
|
{
|
||||||
else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY);
|
print '<tr class="drag drop oddeven';
|
||||||
print '<p style="font-size:120%;" align="right">';
|
if ($line->special_code == "3") print ' order';
|
||||||
print $langs->trans("Customer").': '.$soc->name;
|
print '" id="' . $line->rowid . '">';
|
||||||
print '</p>';
|
print '<td>' . $line->product_label . $line->desc . '</td>';
|
||||||
//}
|
print '<td align="right">' . $line->qty . '</td>';
|
||||||
if ($action=="valid"){
|
print '<td align="right">' . price($line->total_ttc) . '</td>';
|
||||||
print '<p style="font-size:120%;" align="center"><b>'.$invoice->facnumber." ".$langs->trans('BillShortStatusValidated').'</b></p>';
|
print '</tr>';
|
||||||
if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>';
|
}
|
||||||
else print '<center><button type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button><center>';
|
|
||||||
}
|
print '</table>';
|
||||||
if ($action=="search"){
|
print '<p style="font-size:120%;" align="right"><b>' . $langs->trans('TotalTTC');
|
||||||
|
|
||||||
|
if ($conf->global->TAKEPOS_BAR_RESTAURANT) print " " . $langs->trans('Place') . " " . $place;
|
||||||
|
print ': ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ' </b></p>';
|
||||||
|
|
||||||
|
// if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY){
|
||||||
|
|
||||||
|
$soc = new Societe($db);
|
||||||
|
|
||||||
|
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
|
||||||
|
else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY);
|
||||||
|
print '<p style="font-size:120%;" align="right">';
|
||||||
|
print $langs->trans("Customer") . ': ' . $soc->name;
|
||||||
|
print '</p>';
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
if ($action == "valid")
|
||||||
|
{
|
||||||
|
print '<p style="font-size:120%;" align="center"><b>' . $invoice->facnumber . " " . $langs->trans('BillShortStatusValidated') . '</b></p>';
|
||||||
|
if ($conf->global->TAKEPOSCONNECTOR) print '<center><button type="button" onclick="TakeposPrinting(' . $placeid . ');">' . $langs->trans('PrintTicket') . '</button><center>';
|
||||||
|
else print '<center><button type="button" onclick="Print(' . $placeid . ');">' . $langs->trans('PrintTicket') . '</button><center>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == "search")
|
||||||
|
{
|
||||||
print '<center>
|
print '<center>
|
||||||
<input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder='.$langs->trans('Search').'
|
<input type="text" id="search" name="search" onkeyup="Search2();" name="search" style="width:80%;font-size: 150%;" placeholder=' . $langs->trans('Search') . '
|
||||||
</center>';
|
</center>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user