28if (!defined(
'NOTOKENRENEWAL')) {
29 define(
'NOTOKENRENEWAL',
'1');
31if (!defined(
'NOREQUIREMENU')) {
32 define(
'NOREQUIREMENU',
'1');
34if (!defined(
'NOREQUIREHTML')) {
35 define(
'NOREQUIREHTML',
'1');
37if (!defined(
'NOREQUIREAJAX')) {
38 define(
'NOREQUIREAJAX',
'1');
42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
45$langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
47$action =
GETPOST(
'action',
'aZ09');
50if (empty($user->rights->takepos->run)) {
59if ($action==
"split") {
61 $split =
GETPOST(
'split',
'int');
64 $ret = $invoice->fetch(
'',
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
66 $placeid = $invoice->id;
68 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
69 $invoice->socid = $conf->global->$constforcompanyid;
71 $invoice->module_source =
'takepos';
72 $invoice->pos_source = $_SESSION[
"takeposterminal"];
73 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
74 if ($invoice->socid <= 0) {
75 $langs->load(
'errors');
78 $placeid = $invoice->create($user);
82 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-SPLIT)' where rowid=".$placeid;
86 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set fk_facture=".$placeid.
" where rowid=".$line;
88 } elseif ($split==0) {
90 if ($place==
"SPLIT") $place=
"0";
91 $ret = $invoice->fetch(
'',
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
93 $placeid = $invoice->id;
95 $constforcompanyid =
'CASHDESK_ID_THIRDPARTY'.$_SESSION[
"takeposterminal"];
96 $invoice->socid = $conf->global->$constforcompanyid;
98 $invoice->module_source =
'takepos';
99 $invoice->pos_source = $_SESSION[
"takeposterminal"];
100 $invoice->entity = !empty($_SESSION[
"takeposinvoiceentity"]) ? $_SESSION[
"takeposinvoiceentity"] : $conf->entity;
101 if ($invoice->socid <= 0) {
102 $langs->load(
'errors');
105 $placeid = $invoice->create($user);
109 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture set ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")' where rowid=".$placeid;
113 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facturedet set fk_facture=".$placeid.
" where rowid=".$line;
116 $invoice->fetch(
'',
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-SPLIT)');
117 $invoice->update_price();
118 $invoice->fetch(
'',
'(PROV-POS'.$_SESSION[
"takeposterminal"].
'-'.$place.
')');
119 $invoice->update_price();
128if (isset($invoiceid) && $invoiceid > 0) {
129 $invoice->fetch($invoiceid);
131 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
132 $resql = $db->query($sql);
133 $obj = $db->fetch_object($resql);
135 $invoiceid = $obj->rowid;
137 if (!isset($invoiceid)) {
140 $invoice->fetch($invoiceid);
144$arrayofcss = array(
'/takepos/css/pos.css.php');
146 $arrayofcss[] =
'/takepos/css/colorful.css';
155top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
158$arrayOfValidPaymentModes = array();
159$arrayOfValidBankAccount = array();
162<body
class=
"takepossplitphp">
165function Split(selectedline, split) {
167 url:
"split.php?action=split&token=<?php echo newToken(); ?>&line="+selectedline+
"&split="+split+
"&place=<?php echo $place;?>",
168 context: document.body
170 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
171 $(
'#currentplace').find(
'.posinvoiceline').click(function(){
175 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
176 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
183$( document ).ready(
function() {
184 if (parent.place==
'SPLIT') {
189 $(
"#currentplace").load(
"invoice.php?place="+parent.place+
"&invoiceid="+parent.invoiceid,
function() {
190 $(
'#currentplace').find(
'.posinvoiceline')
196 $(
"#splitplace").load(
"invoice.php?place=SPLIT",
function() {
197 $(
'#splitplace').find(
'.posinvoiceline').click(
function(){
204 $(
"#headersplit1").html(
"<?php echo $langs->trans("Place
");?> "+parent.place);
205 $(
"#headersplit2").html(
"<?php echo $langs->trans("SplitSale
");?>");
210<div
class=
"headersplit">
211 <a href=
"#" onclick=
"top.location.href='index.php?place='+parent.place"><div
class=
"headercontent" id=
"headersplit1"></div></a>
214<div
class=
"rowsplit">
215 <div
class=
"splitsale" id=
"currentplace"></div>
218<div
class=
"headersplit">
219 <a href=
"#" onclick=
"top.location.href='index.php?place=SPLIT'"><div
class=
"headercontent" id=
"headersplit2"></div></a>
222<div
class=
"rowsplit">
223 <div
class=
"splitsale" id=
"splitplace"></div>
Class to manage invoices.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return 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 formated error messages to output (Used to show messages on html output).
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput 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.