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);
92 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-SPLIT)'";
93 $sql .=
" WHERE rowid = ".((int) $placeid);
97 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet SET fk_facture = ".((int) $placeid).
" WHERE rowid = ".((int) $line);
99 } elseif ($split == 0) {
101 if ($place ==
"SPLIT") {
104 $ret = $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
106 $placeid = $invoice->id;
108 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
111 $invoice->module_source =
'takepos';
112 $invoice->pos_source = $_SESSION[
"takeposterminal"];
113 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
114 if ($invoice->socid <= 0) {
115 $langs->load(
'errors');
118 $placeid = $invoice->create($user);
123 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
124 $sql .=
" WHERE rowid = ".((int) $placeid);
128 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set fk_facture = ".((int) $placeid).
" where rowid = ".((int) $line);
131 if ($invoice !==
null) {
132 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
133 $invoice->update_price();
135 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
136 $invoice->update_price();
146if (isset($invoiceid) && $invoiceid > 0) {
147 $invoice->fetch($invoiceid);
149 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref = '".
$db->escape(
"(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")").
"'";
150 $resql =
$db->query($sql);
151 $obj =
$db->fetch_object($resql);
153 $invoiceid = $obj->rowid;
155 if (!isset($invoiceid)) {
158 $invoice->fetch($invoiceid);
162$arrayofcss = array(
'/takepos/css/pos.css.php');
164 $arrayofcss[] =
'/takepos/css/colorful.css';
173top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
176$arrayOfValidPaymentModes = array();
177$arrayOfValidBankAccount = array();
180<body
class=
"takepossplitphp">
183function Split(selectedline, split) {
185 url:
"split.php?action=split&token=<?php echo newToken(); ?>&line="+selectedline+
"&split="+split+
"&place=<?php echo $place;?>",
186 context: document.body
188 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
189 $(
'#currentplace').find(
'.posinvoiceline').click(function(){
193 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
194 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
201$( document ).ready(
function() {
202 if (parent.place==
'SPLIT') {
207 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
208 $(
'#currentplace').find(
'.posinvoiceline')
214 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
215 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
222 $(
"#headersplit1").html(
"<?php echo $langs->trans("Place
");?> "+parent.place);
223 $(
"#headersplit2").html(
"<?php echo $langs->trans("SplitSale
");?>");
228<div
class=
"headersplit">
229 <a href=
"#" onclick=
"top.location.href='index.php?place='+parent.place"><div
class=
"headercontent" id=
"headersplit1"></div></a>
232<div
class=
"rowsplit">
233 <div
class=
"splitsale" id=
"currentplace"></div>
236<div
class=
"headersplit">
237 <a href=
"#" onclick=
"top.location.href='index.php?place=SPLIT'"><div
class=
"headercontent" id=
"headersplit2"></div></a>
240<div
class=
"rowsplit">
241 <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.