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')) {
72 $sourceref =
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.($split == 1 ? $place :
'SPLIT').
')';
75 $ret = $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
77 $placeid = $invoice->id;
79 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
82 $invoice->module_source =
'takepos';
83 $invoice->pos_source = $_SESSION[
"takeposterminal"];
84 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
85 if ($invoice->socid <= 0) {
86 $langs->load(
'errors');
89 $placeid = $invoice->create($user);
93 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-SPLIT)'";
94 $sql .=
" WHERE rowid = ".((int) $placeid);
99 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet SET fk_facture = ".((int) $placeid).
" WHERE rowid = ".((int) $line);
100 $sql .=
" AND fk_facture IN (SELECT f.rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.ref = '".$db->escape($sourceref).
"'";
101 $sql .=
" AND f.fk_statut = ".Facture::STATUS_DRAFT.
" AND f.entity IN (".
getEntity(
'invoice').
"))";
104 } elseif ($split == 0) {
106 if ($place ==
"SPLIT") {
109 $ret = $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
111 $placeid = $invoice->id;
113 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
116 $invoice->module_source =
'takepos';
117 $invoice->pos_source = $_SESSION[
"takeposterminal"];
118 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] :
$conf->entity;
119 if ($invoice->socid <= 0) {
120 $langs->load(
'errors');
123 $placeid = $invoice->create($user);
128 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
129 $sql .=
" WHERE rowid = ".((int) $placeid);
134 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet SET fk_facture = ".((int) $placeid).
" WHERE rowid = ".((int) $line);
135 $sql .=
" AND fk_facture IN (SELECT f.rowid FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.ref = '".$db->escape($sourceref).
"'";
136 $sql .=
" AND f.fk_statut = ".Facture::STATUS_DRAFT.
" AND f.entity IN (".
getEntity(
'invoice').
"))";
140 if ($invoice !==
null) {
141 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
142 $invoice->update_price();
144 $invoice->fetch(0,
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
145 $invoice->update_price();
155if (isset($invoiceid) && $invoiceid > 0) {
156 $invoice->fetch($invoiceid);
158 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
159 $resql = $db->query($sql);
160 $obj = $db->fetch_object($resql);
162 $invoiceid = $obj->rowid;
164 if (!isset($invoiceid)) {
167 $invoice->fetch($invoiceid);
171$arrayofcss = array(
'/takepos/css/pos.css.php');
173 $arrayofcss[] =
'/takepos/css/colorful.css';
182top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
185$arrayOfValidPaymentModes = array();
186$arrayOfValidBankAccount = array();
189<body
class=
"takepossplitphp">
192function Split(selectedline, split) {
194 url:
"split.php?action=split&token=<?php echo newToken(); ?>&line="+selectedline+
"&split="+split+
"&place=<?php echo $place;?>",
195 context: document.body
197 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
198 $(
'#currentplace').find(
'.posinvoiceline').click(function(){
202 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
203 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
210$( document ).ready(
function() {
211 if (parent.place==
'SPLIT') {
216 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
217 $(
'#currentplace').find(
'.posinvoiceline')
223 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
224 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
231 $(
"#headersplit1").html(
"<?php echo $langs->trans("Place
");?> "+parent.place);
232 $(
"#headersplit2").html(
"<?php echo $langs->trans("SplitSale
");?>");
237<div
class=
"headersplit">
238 <a href=
"#" onclick=
"top.location.href='index.php?place='+parent.place"><div
class=
"headercontent" id=
"headersplit1"></div></a>
241<div
class=
"rowsplit">
242 <div
class=
"splitsale" id=
"currentplace"></div>
245<div
class=
"headersplit">
246 <a href=
"#" onclick=
"top.location.href='index.php?place=SPLIT'"><div
class=
"headercontent" id=
"headersplit2"></div></a>
249<div
class=
"rowsplit">
250 <div
class=
"splitsale" id=
"splitplace"></div>
Class to manage invoices.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
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).
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.