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;
273 $langs->load(
"cashdesk");
279 $societe =
new Societe($this->db);
280 $nametouse = $langs->trans(
"DefaultPOSThirdLabel");
282 $searchcompanyid = $societe->fetch(0, $nametouse);
283 if ($searchcompanyid == 0) {
284 $societe->name = $nametouse;
285 $societe->client = 1;
286 $societe->code_client =
'-1';
287 $societe->code_fournisseur =
'-1';
288 $societe->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
289 $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.";
291 $searchcompanyid = $societe->create($user);
293 if ($searchcompanyid > 0) {
303 $cate_arbo = $categories->get_full_arbo(
'product', 0, 1);
304 if (is_array($cate_arbo)) {
308 $category->label = $langs->trans(
"DefaultPOSCatLabel");
309 $category->type = Categorie::TYPE_PRODUCT;
311 $result = $category->create($user);
314 dolibarr_set_const($this->db,
'TAKEPOS_ROOT_CATEGORY_ID', $result,
'chaine', 0,
'Id of category for products visible in TakePOS',
$conf->entity);
333 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
334 $cashaccount =
new Account($this->db);
335 $searchaccountid = $cashaccount->fetch(0,
"CASH-POS");
336 if ($searchaccountid == 0) {
337 $cashaccount->ref =
"CASH-POS";
338 $cashaccount->label = $langs->trans(
"DefaultCashPOSLabel");
341 $cashaccount->country_id = $mysoc->country_id ? $mysoc->country_id : 1;
342 $cashaccount->date_solde =
dol_now();
343 $idjournal =
dol_getIdFromCode($this->db,
'BQ',
'accounting_journal',
'code',
'rowid');
344 $cashaccount->fk_accountancy_journal = (int) $idjournal;
345 $searchaccountid = $cashaccount->create($user);
347 if ($searchaccountid > 0) {
348 dolibarr_set_const($this->db,
"CASHDESK_ID_BANKACCOUNT_CASH1", $searchaccountid,
'chaine', 0,
'',
$conf->entity);
354 $result = $this->
_load_tables(
'/install/mysql/',
'takepos');
360 $this->
remove($options);
364 return $this->
_init($sql, $options);
375 public function remove($options =
'')
379 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.