28include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50 $this->numero = 50150;
52 $this->rights_class =
'takepos';
56 $this->family =
"portal";
58 $this->module_position =
'45';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
65 $this->
description =
"Point of sales module (Touch Screen POS)";
67 $this->descriptionlong =
"Point Of Sales (compliant with touch screen)";
70 $this->version =
'dolibarr';
72 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
76 $this->picto =
'cash-register';
82 $this->module_parts = array(
96 $this->dirs = array();
99 $this->config_page_url = array(
"setup.php@takepos");
102 $this->hidden =
false;
104 $this->depends = array(
'always'=>array(
"modBanque",
"modFacture",
"modProduct",
"modCategorie"),
'FR'=>array(
'modBlockedLog'));
105 $this->requiredby = array();
106 $this->conflictwith = array();
107 $this->langfiles = array(
"cashdesk");
108 $this->phpmin = array(7, 0);
109 $this->need_dolibarr_version = array(4, 0);
110 $this->warnings_activation = array(
'FR'=>
'WarningNoteModulePOSForFrenchLaw');
111 $this->warnings_activation_ext = array();
120 $this->
const = array(
125 if (!isModEnabled(
'takepos')) {
127 $conf->takepos->enabled = 0;
132 $this->tabs = array();
161 $this->dictionaries = array();
166 $this->boxes = array(
175 $this->cronjobs = array(
184 $this->rights = array();
189 $this->rights[$r][0] = 50151;
190 $this->rights[$r][1] =
'Use Point Of Sale (record a sale, add products, record payment)';
191 $this->rights[$r][2] =
'a';
192 $this->rights[$r][3] = 0;
193 $this->rights[$r][4] =
'run';
196 $this->rights[$r][0] = 50152;
197 $this->rights[$r][1] =
'Can modify added sales lines (prices, discount)';
198 $this->rights[$r][2] =
'a';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'editlines';
203 $this->rights[$r][0] = 50153;
204 $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';
205 $this->rights[$r][2] =
'a';
206 $this->rights[$r][3] = 0;
207 $this->rights[$r][4] =
'editorderedlines';
211 $this->menu = array();
217 $this->menu[$r++] = array(
'fk_menu'=>
'',
219 'titre'=>
'PointOfSaleShort',
220 'mainmenu'=>
'takepos',
222 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
223 'url'=>
'/takepos/index.php',
225 'position'=>1000 + $r,
226 'enabled'=>
'isModEnabled("takepos")',
227 'perms'=>
'$user->hasRight("takepos", "run")',
269 public function init($options =
'')
271 global $conf, $langs, $user, $mysoc;
272 $langs->load(
"cashdesk");
274 dolibarr_set_const($this->db,
"TAKEPOS_PRINT_METHOD",
"browser",
'chaine', 0,
'', $conf->entity);
278 $societe =
new Societe($this->db);
279 $nametouse = $langs->trans(
"DefaultPOSThirdLabel");
281 $searchcompanyid = $societe->fetch(0, $nametouse);
282 if ($searchcompanyid == 0) {
283 $societe->name = $nametouse;
284 $societe->client = 1;
285 $societe->code_client =
'-1';
286 $societe->code_fournisseur =
'-1';
287 $societe->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
288 $societe->note_private =
"Default customer automatically 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.";
290 $searchcompanyid = $societe->create($user);
292 if ($searchcompanyid > 0) {
294 dolibarr_set_const($this->db,
"CASHDESK_ID_THIRDPARTY1", $searchcompanyid,
'chaine', 0,
'', $conf->entity);
302 $cate_arbo = $categories->get_full_arbo(
'product', 0, 1);
303 if (is_array($cate_arbo)) {
307 $category->label = $langs->trans(
"DefaultPOSCatLabel");
308 $category->type = Categorie::TYPE_PRODUCT;
310 $result = $category->create($user);
313 dolibarr_set_const($this->db,
'TAKEPOS_ROOT_CATEGORY_ID', $result,
'chaine', 0,
'Id of category for products visible in TakePOS', $conf->entity);
332 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
333 $cashaccount =
new Account($this->db);
334 $searchaccountid = $cashaccount->fetch(0,
"CASH-POS");
335 if ($searchaccountid == 0) {
336 $cashaccount->ref =
"CASH-POS";
337 $cashaccount->label = $langs->trans(
"DefaultCashPOSLabel");
340 $cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
341 $cashaccount->date_solde =
dol_now();
342 $searchaccountid = $cashaccount->create($user);
344 if ($searchaccountid > 0) {
345 dolibarr_set_const($this->db,
"CASHDESK_ID_BANKACCOUNT_CASH1", $searchaccountid,
'chaine', 0,
'', $conf->entity);
351 $result = $this->
_load_tables(
'/install/mysql/',
'takepos');
357 $this->
remove($options);
361 return $this->
_init($sql, $options);
372 public function remove($options =
'')
376 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.
const TYPE_CASH
Cash account.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.