diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 28e87394089..7ddbc71f3e9 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -89,4 +89,5 @@ Browser=Browser BrowserMethodDescription=Simple and easy receipt printing. Only a few parameters to configure the receipt. Print via browser. TakeposConnectorMethodDescription=External module with extra features. Posibility to print from de cloud. PrintMethod=Print method -ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. \ No newline at end of file +ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. +ByTerminal=By terminal diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 5b6fe25af44..eef9497e9db 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // If socid provided by ajax company selector if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) @@ -79,7 +80,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); - //$res = dolibarr_set_const($db, "TAKEPOS_HEAD_BAR", GETPOST('TAKEPOS_HEAD_BAR', 'int'), 'int', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ADDON", GETPOST('TAKEPOS_ADDON', 'alpha'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -241,6 +242,63 @@ if (is_array($formmail->lines_model)) { print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE, 'None', 1, 0, '', 0, 0, 0, '', '', 1); print "\n"; +// Numbering module +print ''; +print $langs->trans("BillsNumberingModule"); +print ''; +$array = array(0=>$langs->trans("Default"), "terminal"=>$langs->trans("ByTerminal")); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/facture/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))]=preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + } + } + } + } + closedir($handle); + } + } +} + +print $form->selectarray('TAKEPOS_ADDON', $array, (empty($conf->global->TAKEPOS_ADDON) ? '0' : $conf->global->TAKEPOS_ADDON), 0); +print "\n"; + print ''; print ''; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 1107f9101c7..08ca05bb109 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -90,6 +90,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') > 0 ? GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') : ''), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); if (!$res > 0) $error++; @@ -251,6 +253,66 @@ print ''; print ''; print ''; +// Numbering module +if ($conf->global->TAKEPOS_ADDON=="terminal"){ + print ''; + print $langs->trans("BillsNumberingModule"); + print ''; + $array = array(0=>$langs->trans("Default")); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/facture/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))]=preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + } + } + } + } + closedir($handle); + } + } + } + print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, (empty($conf->global->{'TAKEPOS_ADDON'.$terminaltouse}) ? '0' : $conf->global->{'TAKEPOS_ADDON'.$terminaltouse}), 0); + print "\n"; + print ''; + print ''; +} + print ''; print ''; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index fc4ae6ee23e..e4ad387e1cc 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -171,7 +171,8 @@ if ($action == 'valid' && $user->rights->facture->creer) $sav_FACTURE_ADDON=''; if (! empty($conf->global->TAKEPOS_ADDON)) { $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; + if ($conf->global->TAKEPOS_ADDON=="terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; + else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; } $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];