28 if (!defined(
'NOCSRFCHECK')) define(
'NOCSRFCHECK',
'1');
29 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
30 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
31 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
32 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
33 if (!defined(
'NOBROWSERNOTIF')) define(
'NOBROWSERNOTIF',
'1');
35 require
'../../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
38 $category =
GETPOST(
'category',
'alpha');
39 $action =
GETPOST(
'action',
'aZ09');
40 $term =
GETPOST(
'term',
'alpha');
43 if (empty($user->rights->takepos->run)) {
52 if ($action ==
'getProducts') {
54 if ($category ==
"supplements") $category = $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY;
55 $result = $object->fetch($category);
58 $prods = $object->getObjectsInCateg(
"product", 0, 0, 0, $conf->global->TAKEPOS_SORTPRODUCTFIELD,
'ASC');
60 if (is_array($prods) && count($prods) > 0)
62 foreach ($prods as $prod)
68 echo json_encode($prods);
70 echo
'Failed to load category with id='.$category;
72 } elseif ($action ==
'search' && $term !=
'') {
74 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
77 $result = $thirdparty->fetch(
'',
'',
'', $term);
79 if ($result && $thirdparty->id > 0) {
82 'rowid' => $thirdparty->id,
83 'name' => $thirdparty->name,
84 'barcode' => $thirdparty->barcode,
85 'object' =>
'thirdparty'
87 echo json_encode($rows);
92 $filteroncategids =
'';
93 if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
96 $arrayofcateg = $object->get_full_arbo(
'product', $conf->global->TAKEPOS_ROOT_CATEGORY_ID, 1);
97 if (is_array($arrayofcateg) && count($arrayofcateg) > 0) {
98 foreach ($arrayofcateg as $val)
100 $filteroncategids .= ($filteroncategids ?
', ' :
'').$val[
'id'];
105 $sql =
'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.
'product as p';
106 $sql .=
' WHERE entity IN ('.getEntity(
'product').
')';
107 if ($filteroncategids) {
108 $sql .=
' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.
'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.
'))';
110 $sql .=
' AND tosell = 1';
112 $resql = $db->query($sql);
116 while ($obj = $db->fetch_object(
$resql)) {
118 'rowid' => $obj->rowid,
120 'label' => $obj->label,
121 'tosell' => $obj->tosell,
122 'tobuy' => $obj->tobuy,
123 'barcode' => $obj->barcode,
124 'price' => $obj->price,
125 'object' =>
'product'
129 echo json_encode($rows);
131 echo
'Failed to search product : '.$db->lasterror();
133 } elseif ($action ==
"opendrawer" && $term !=
'') {
134 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
137 if ($conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$term} > 0) {
138 $printer->initPrinter($conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$term});
143 } elseif ($action ==
"printinvoiceticket" && $term !=
'' && $id > 0 && !empty($user->rights->facture->lire)) {
144 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
145 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
148 if (($conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$term} > 0 || $conf->global->TAKEPOS_PRINT_METHOD ==
"takeposconnector") && $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term} > 0) {
151 $ret = $printer->sendToPrinter($object, $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$term});
153 } elseif ($action ==
'getInvoice') {
154 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
161 echo json_encode($object);
162 } elseif ($action ==
'thecheck') {
163 $place =
GETPOST(
'place',
'alpha');
164 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
165 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
167 $printer->sendToPrinter($object, $conf->global->{
'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{
'TAKEPOS_PRINTER_TO_USE'.$term});
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
Class to manage Receipt Printers.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage invoices.