30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
52$langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
54$action =
GETPOST(
'action',
'aZ09');
57if (!$user->hasRight(
'takepos',
'run')) {
66if ($action ==
"split" && $user->hasRight(
'takepos',
'run')) {
73 $ret = $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
75 $placeid = $invoice->id;
77 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
80 $invoice->module_source =
'takepos';
81 $invoice->pos_source = $_SESSION[
"takeposterminal"];
82 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
83 if ($invoice->socid <= 0) {
84 $langs->load(
'errors');
87 $placeid = $invoice->create($user);
91 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-SPLIT)'";
92 $sql .=
" WHERE rowid = ".((int) $placeid);
96 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet SET fk_facture = ".((int) $placeid).
" WHERE rowid = ".((int) $line);
98 } elseif ($split == 0) {
100 if ($place ==
"SPLIT") {
103 $ret = $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
105 $placeid = $invoice->id;
107 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
110 $invoice->module_source =
'takepos';
111 $invoice->pos_source = $_SESSION[
"takeposterminal"];
112 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
113 if ($invoice->socid <= 0) {
114 $langs->load(
'errors');
117 $placeid = $invoice->create($user);
122 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
123 $sql .=
" WHERE rowid = ".((int) $placeid);
127 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set fk_facture=".$placeid.
" where rowid=".$line;
130 if ($invoice !==
null) {
131 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
132 $invoice->update_price();
134 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
135 $invoice->update_price();
145if (isset($invoiceid) && $invoiceid > 0) {
146 $invoice->fetch($invoiceid);
148 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
149 $resql = $db->query($sql);
150 $obj = $db->fetch_object($resql);
152 $invoiceid = $obj->rowid;
154 if (!isset($invoiceid)) {
157 $invoice->fetch($invoiceid);
161$arrayofcss = array(
'/takepos/css/pos.css.php');
163 $arrayofcss[] =
'/takepos/css/colorful.css';
172top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
175$arrayOfValidPaymentModes = array();
176$arrayOfValidBankAccount = array();
179<body
class=
"takepossplitphp">
182function Split(selectedline, split) {
184 url:
"split.php?action=split&token=<?php echo newToken(); ?>&line="+selectedline+
"&split="+split+
"&place=<?php echo $place;?>",
185 context: document.body
187 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
188 $(
'#currentplace').find(
'.posinvoiceline').click(function(){
192 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
193 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
200$( document ).ready(
function() {
201 if (parent.place==
'SPLIT') {
206 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
207 $(
'#currentplace').find(
'.posinvoiceline')
213 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
214 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
221 $(
"#headersplit1").html(
"<?php echo $langs->trans("Place
");?> "+parent.place);
222 $(
"#headersplit2").html(
"<?php echo $langs->trans("SplitSale
");?>");
227<div
class=
"headersplit">
228 <a href=
"#" onclick=
"top.location.href='index.php?place='+parent.place"><div
class=
"headercontent" id=
"headersplit1"></div></a>
231<div
class=
"rowsplit">
232 <div
class=
"splitsale" id=
"currentplace"></div>
235<div
class=
"headersplit">
236 <a href=
"#" onclick=
"top.location.href='index.php?place=SPLIT'"><div
class=
"headercontent" id=
"headersplit2"></div></a>
239<div
class=
"rowsplit">
240 <div
class=
"splitsale" id=
"splitplace"></div>
Class to manage invoices.
dol_now($mode='gmt')
Return date for now.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.