27include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
49 $this->numero = 50150;
51 $this->rights_class =
'takepos';
55 $this->family =
"portal";
57 $this->module_position =
'60';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
64 $this->
description =
"Point of sales module (Touch Screen POS)";
66 $this->descriptionlong =
"Point Of Sales (compliant with touch screen)";
69 $this->version =
'dolibarr';
71 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
75 $this->picto =
'cash-register';
81 $this->module_parts = array(
95 $this->dirs = array();
98 $this->config_page_url = array(
"setup.php@takepos");
101 $this->hidden =
false;
103 $this->depends = array(
'always'=>array(
"modBanque",
"modFacture",
"modProduct",
"modCategorie"),
'FR'=>array(
'modBlockedLog'));
104 $this->requiredby = array();
105 $this->conflictwith = array();
106 $this->langfiles = array(
"cashdesk");
107 $this->phpmin = array(7, 0);
108 $this->need_dolibarr_version = array(4, 0);
109 $this->warnings_activation = array(
'FR'=>
'WarningNoteModulePOSForFrenchLaw');
110 $this->warnings_activation_ext = array();
119 $this->
const = array(
124 if (!isset($conf->takepos) || !isset($conf->takepos->enabled)) {
126 $conf->takepos->enabled = 0;
131 $this->tabs = array();
160 $this->dictionaries = array();
165 $this->boxes = array(
174 $this->cronjobs = array(
183 $this->rights = array();
188 $this->rights[$r][0] = 50151;
189 $this->rights[$r][1] =
'Use Point Of Sale (record a sale, add products, record payment)';
190 $this->rights[$r][2] =
'a';
191 $this->rights[$r][3] = 0;
192 $this->rights[$r][4] =
'run';
195 $this->rights[$r][0] = 50152;
196 $this->rights[$r][1] =
'Can modify added sales lines (prices, discount)';
197 $this->rights[$r][2] =
'a';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'editlines';
202 $this->rights[$r][0] = 50153;
203 $this->rights[$r][1] =
'Edit ordered sales lines (useful only when option "Order printers" has been enabled). Allow to edit sales lines even after the order has been printed';
204 $this->rights[$r][2] =
'a';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'editorderedlines';
210 $this->menu = array();
216 $this->menu[$r++] = array(
'fk_menu'=>
'',
218 'titre'=>
'PointOfSaleShort',
219 'mainmenu'=>
'takepos',
221 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
222 'url'=>
'/takepos/index.php',
224 'position'=>1000 + $r,
225 'enabled'=>
'isModEnabled("takepos")',
226 'perms'=>
'$user->hasRight("takepos", "run")',
268 public function init($options =
'')
270 global $conf, $langs, $user, $mysoc;
271 $langs->load(
"cashdesk");
273 dolibarr_set_const($this->db,
"TAKEPOS_PRINT_METHOD",
"browser",
'chaine', 0,
'', $conf->entity);
277 $societe =
new Societe($this->db);
278 $nametouse = $langs->trans(
"DefaultPOSThirdLabel");
280 $searchcompanyid = $societe->fetch(0, $nametouse);
281 if ($searchcompanyid == 0) {
282 $societe->name = $nametouse;
283 $societe->client = 1;
284 $societe->code_client = -1;
285 $societe->code_fournisseur = -1;
286 $societe->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
287 $societe->note_private =
"Default customer automaticaly created by Point Of Sale module activation. Can be used as the default generic customer in the Point Of Sale setup. Can also be edited or removed if you don't need a generic customer.";
289 $searchcompanyid = $societe->create($user);
291 if ($searchcompanyid > 0) {
293 dolibarr_set_const($this->db,
"CASHDESK_ID_THIRDPARTY1", $searchcompanyid,
'chaine', 0,
'', $conf->entity);
301 $cate_arbo = $categories->get_full_arbo(
'product', 0, 1);
302 if (is_array($cate_arbo)) {
303 if (!count($cate_arbo)) {
306 $category->label = $langs->trans(
"DefaultPOSCatLabel");
307 $category->type = Categorie::TYPE_PRODUCT;
309 $result = $category->create($user);
329 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
330 $cashaccount =
new Account($this->db);
331 $searchaccountid = $cashaccount->fetch(0,
"CASH-POS");
332 if ($searchaccountid == 0) {
333 $cashaccount->ref =
"CASH-POS";
334 $cashaccount->label = $langs->trans(
"DefaultCashPOSLabel");
335 $cashaccount->courant = 2;
336 $cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
337 $cashaccount->date_solde =
dol_now();
338 $searchaccountid = $cashaccount->create($user);
340 if ($searchaccountid > 0) {
341 dolibarr_set_const($this->db,
"CASHDESK_ID_BANKACCOUNT_CASH1", $searchaccountid,
'chaine', 0,
'', $conf->entity);
347 $result = $this->
_load_tables(
'/install/mysql/',
'takepos');
353 $this->
remove($options);
357 return $this->
_init($sql, $options);
368 public function remove($options =
'')
372 return $this->
_remove($sql, $options);
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Class to manage bank accounts.
Class to manage categories.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to manage third parties objects (customers, suppliers, prospects...)
Class to describe and enable module TakePos.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
$conf db name
Only used if Module[ID]Name translation string is not found.