From 70ebc61c1f1c228353a683a15f6fe0e628b0a8a2 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 12 Mar 2020 17:43:59 +0100 Subject: [PATCH] Module TakePos - NEW add numbering module for cash desk --- htdocs/compta/facture/class/facture.class.php | 101 ++++---- .../takepos/mod_takepos_ref_simple.php | 175 +++++++++++++ .../takepos/mod_takepos_ref_universal.php | 146 +++++++++++ .../core/modules/takepos/modules_takepos.php | 111 ++++++++ htdocs/langs/en_US/cashdesk.lang | 2 + htdocs/langs/fr_FR/cashdesk.lang | 2 + htdocs/takepos/admin/setup.php | 242 +++++++++++++----- htdocs/takepos/invoice.php | 20 +- 8 files changed, 685 insertions(+), 114 deletions(-) create mode 100644 htdocs/core/modules/takepos/mod_takepos_ref_simple.php create mode 100644 htdocs/core/modules/takepos/mod_takepos_ref_universal.php create mode 100644 htdocs/core/modules/takepos/modules_takepos.php diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b679537cb1a..da9c4f57c7a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3699,63 +3699,77 @@ class Facture extends CommonInvoice public function getNextNumRef($soc, $mode = 'next') { global $conf, $langs; - $langs->load("bills"); - // Clean parameters (if not defined or using deprecated value) - if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; - elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + if ($this->module_source == 'takepos') { + $langs->load('cashdesk@cashdesk'); - if (!empty($conf->global->FACTURE_ADDON)) - { - dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); + $moduleName = 'takepos'; + $moduleSourceName = 'Takepos'; + $addonConstName = 'TAKEPOS_REF_ADDON'; + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->TAKEPOS_REF_ADDON)) $conf->global->TAKEPOS_REF_ADDON = 'mod_takepos_ref_simple'; + + $addon = $conf->global->TAKEPOS_REF_ADDON; + } else { + $langs->load('bills'); + + $moduleName = 'facture'; + $moduleSourceName = 'Invoice'; + $addonConstName = 'FACTURE_ADDON'; + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; + elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; + + $addon = $conf->global->FACTURE_ADDON; + } + + if (!empty($addon)) { + dol_syslog("Call getNextNumRef with " . $addonConstName . " = " . $conf->global->FACTURE_ADDON . ", thirdparty=" . $soc->nom . ", type=" . $soc->typent_code, LOG_DEBUG); $mybool = false; - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; + $file = $addon . '.php'; + $classname = $addon; // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array)$conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/facture/"); + $dir = dol_buildpath($reldir . 'core/modules/' . $moduleName . '/'); // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) - { - $mybool |= include_once $dir.$file; - } - } - - // For compatibility - if (!$mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/', '', $classname); - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; - - // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; - } + if (is_file($dir . $file) && is_readable($dir . $file)) { + $mybool |= include_once $dir . $file; } } - if (!$mybool) - { - dol_print_error('', "Failed to include file ".$file); + // For compatibility + if (!$mybool) { + $file = $addon . '/' . $addon . '.modules.php'; + $classname = 'mod_' . $moduleName . '_' . $addon; + $classname = preg_replace('/\-.*$/', '', $classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) { + $dir = $dirroot . '/core/modules/' . $moduleName . '/'; + + // Load file with numbering class (if found) + if (is_file($dir . $file) && is_readable($dir . $file)) { + $mybool |= include_once $dir . $file; + } + } + } + + if (!$mybool) { + dol_print_error('', 'Failed to include file ' . $file); return ''; } $obj = new $classname(); - $numref = ""; $numref = $obj->getNextValue($soc, $this, $mode); /** @@ -3764,17 +3778,14 @@ class Facture extends CommonInvoice */ if ($mode != 'last' && !$numref) { $this->error = $obj->error; - //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); - return ""; + return ''; } return $numref; - } - else - { - $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); - return ""; + } else { + $langs->load('errors'); + print $langs->trans('Error') . ' ' . $langs->trans('ErrorModuleSetupNotComplete', $langs->transnoentitiesnoconv($moduleSourceName)); + return ''; } } diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php new file mode 100644 index 00000000000..18039198a6e --- /dev/null +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -0,0 +1,175 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2020 Open-DSI + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/takepos/mod_takepos_ref_simple.php + * \ingroup takepos + * \brief File with Simple ref numbering module for takepos + */ +dol_include_once('/core/modules/takepos/modules_takepos.php'); + +/** + * Class to manage ref numbering of takepos cards with rule Simple. + */ +class mod_takepos_ref_simple extends ModeleNumRefTakepos +{ + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + var $prefix = 'TK'; + var $error = ''; + var $nom = 'Simple'; + + /** + * Return description of numbering module + * + * @return string Text with description + */ + function info() + { + global $langs; + + return $langs->trans('SimpleNumRefModelDesc', $this->prefix . '0-'); + } + + /** + * Return an example of numbering module values + * + * @return string Example + */ + function getExample() + { + return $this->prefix . '0-0501-0001'; + } + + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + global $conf, $langs, $db; + + $pryymm = ''; + $max = ''; + + $posindice = 8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facture"; + $sql .= " WHERE ref LIKE '" . $this->prefix . "____-%'"; + $sql .= " AND entity = " . $conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $row = $db->fetch_row($resql); + if ($row) { + $pryymm = substr($row[0], 0, 6); + $max = $row[0]; + } + } + + if (!$pryymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $pryymm)) { + return true; + } else { + $langs->load("errors"); + $this->error = $langs->trans('ErrorNumRefModel', $max); + return false; + } + } + + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next value + */ + function getNextValue($objsoc = null, $invoice = null, $mode = 'next') + { + global $db; + + $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0; + + // D'abord on recupere la valeur max + $posindice = strlen($this->prefix . $pos_source . '-____-') + 1; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max"; // This is standard SQL + $sql .= " FROM " . MAIN_DB_PREFIX . "facture"; + $sql .= " WHERE ref LIKE '" . $this->prefix . $pos_source . "-____-%'"; + $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max = 0; + } else { + dol_syslog(get_class($this) . "::getNextValue", LOG_DEBUG); + return -1; + } + + if ($mode == 'last') + { + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max); + + $ref = ''; + $sql = "SELECT ref as ref"; + $sql .= " FROM ". MAIN_DB_PREFIX . "facture"; + $sql .= " WHERE ref LIKE '" . $this->prefix . $pos_source . "-____-" . $num . "'"; + $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")"; + $sql .= " ORDER BY ref DESC"; + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) $ref = $obj->ref; + } + else dol_print_error($db); + + return $ref; + } + elseif ($mode == 'next') + { + $date = $invoice->date; // This is invoice date (not creation date) + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max+1); + + dol_syslog(get_class($this)."::getNextValue return " . $this->prefix . $pos_source . '-' . $yymm . '-' . $num); + return $this->prefix . $pos_source . '-' . $yymm . '-' . $num; + } + else dol_print_error('', 'Bad parameter for getNextValue'); + } + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param Object $objforref Object for number to search + * @return string Next free value + */ + function getNumRef($objsoc, $objforref) + { + return $this->getNextValue($objsoc, $objforref); + } +} diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php new file mode 100644 index 00000000000..aff9f373528 --- /dev/null +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2020 Open-DSI + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/takepos/mod_takepos_ref_universal.php + * \ingroup takepos + * \brief File with Universal ref numbering module for takepos + */ +dol_include_once('/core/modules/takepos/modules_takepos.php'); + +/** + * Class to manage ref numbering of takepos cards with rule universal. + */ +class mod_takepos_ref_universal extends ModeleNumRefTakepos +{ + var $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + var $error = ''; + var $nom = 'Universal'; + + /** + * Renvoi la description du modele de numerotation + * + * @return string Texte descripif + */ + function info() + { + global $conf, $langs; + + $langs->load('cashdesk@cashdesk'); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc') . "
\n"; + $texte .= '
'; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + + $tooltip = $langs->trans('GenericMaskCodes', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk')); + $tooltip .= $langs->trans('GenericMaskCodes2'); + $tooltip .= $langs->trans('GenericMaskCodes3'); + $tooltip .= $langs->trans('GenericMaskCodes4a', $langs->transnoentities('CashDesk'), $langs->transnoentities('CashDesk')); + $tooltip .= $langs->trans('GenericMaskCodes5'); + $tooltip .= $langs->trans('CashDeskGenericMaskCodes6'); + + // Parametrage du prefix + $texte .= ''; + $texte .= ''; + + $texte .= ''; + + $texte .= ''; + + $texte .= '
' . $langs->trans("Mask") . ':' . $form->textwithpicto('', $tooltip, 1, 1) . ' 
'; + $texte .= '
'; + + return $texte; + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $conf, $langs, $mysoc; + + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client = $old_code_client; + + if (!$numExample) { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string Value if KO, <0 if KO + */ + function getNextValue($objsoc = 0, $invoice = null, $mode = 'next') + { + global $db, $conf; + + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; + + // On defini critere recherche compteur + $mask = $conf->global->TAKEPOS_REF_UNIVERSAL_MASK; + + if (!$mask) { + $this->error = 'NotConfigured'; + return 0; + } + + // Get entities + $entity = getEntity('invoicenumber', 1, $invoice); + + $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0; + $mask = str_replace('{TN}' , $pos_source, $mask); + $numFinal = get_next_value($db, $mask, 'facture', 'ref', '', $objsoc, $invoice->date, $mode, false, null, $entity); + + return $numFinal; + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param Object $objforref Object for number to search + * @return string Next free value + */ + function getNumRef($objsoc, $objforref) + { + return $this->getNextValue($objsoc, $objforref); + } +} + diff --git a/htdocs/core/modules/takepos/modules_takepos.php b/htdocs/core/modules/takepos/modules_takepos.php new file mode 100644 index 00000000000..df327a87a1c --- /dev/null +++ b/htdocs/core/modules/takepos/modules_takepos.php @@ -0,0 +1,111 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2020 Open-DSI + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/takepos/modules_takepos.php + * \ingroup takepos + * \brief Fichier contenant la classe mere de numerotation des tickets de caisse + */ + + +/** + * \class ModeleNumRefTakepos + * \brief Classe mere des modeles de numerotation des tickets de caisse + */ +abstract class ModeleNumRefTakepos +{ + var $error=''; + public $version = ''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Renvoi la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("cashdesk@cashdesk"); + return $langs->trans("NoDescription"); + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load('cashdesk@cashdesk'); + return $langs->trans('NoExample'); + } + + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } + + /** + * Renvoi prochaine valeur attribuee + * + * @return string Valeur + */ + function getNextValue() + { + global $langs; + return $langs->trans('NotAvailable'); + } + + /** + * Renvoi version du module numerotation + * + * @return string Valeur + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans('VersionDevelopment'); + if ($this->version == 'experimental') return $langs->trans('VersionExperimental'); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans('NotAvailable'); + } +} \ No newline at end of file diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index d4355566872..1d32b77e267 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -92,3 +92,5 @@ PrintMethod=Print method ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. ByTerminal=By terminal TakeposNumpadUsePaymentIcon=Use payment icon on numpad +CashDeskRefNumberingModules=Numbering module for cash desk +CashDeskGenericMaskCodes6 =
{TN} tag is used to add the terminal number diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index 03ca0155daa..07f1660e00b 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -83,3 +83,5 @@ ProductSupplements=Suppléments de produit SupplementCategory=Catégorie des suppléments SortProductField=Champ pour le tri des produits TakeposNumpadUsePaymentIcon=Utilisation d'icônes sur les touches des modes de règlement du pavé numérique +CashDeskRefNumberingModules=Modèles de numérotation des caisses +CashDeskGenericMaskCodes6 =
La balise {TN} permet de rajouter le numéro du terminal diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 307eafc585d..832417ffd30 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -43,7 +43,7 @@ if (!$user->admin) accessforbidden(); $langs->loadLangs(array("admin", "cashdesk")); -global $db; +global $db, $mysoc; $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; $sql .= " WHERE entity IN (".getEntity('c_paiement').")"; @@ -57,10 +57,14 @@ if ($resql) { } } +$action = GETPOST('action','alpha'); + /* * Actions */ -if (GETPOST('action', 'alpha') == 'set') +$error = 0; + +if ($action == 'set') { $db->begin(); if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; @@ -98,13 +102,29 @@ if (GETPOST('action', 'alpha') == 'set') if (!$error) { $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); } +} elseif ($action == 'updateMask') { + $maskconst = GETPOST('maskconst', 'alpha'); + $maskvalue = GETPOST('maskvalue', 'alpha'); + if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } +} elseif ($action == 'setrefmod') { + $value = GETPOST('value', 'alpha'); + dolibarr_set_const($db, "TAKEPOS_REF_ADDON", $value, 'chaine', 0, '', $conf->entity); +} + +if ($action != '') { + if (!$error) { + setEventMessage($langs->trans('SetupSaved')); + } else { + setEventMessages($langs->trans('Error'), null, 'errors'); + } } /* @@ -122,6 +142,110 @@ $head = takepos_prepare_head(); dol_fiche_head($head, 'setup', 'TakePOS', -1); print '
'; +// Numbering modules +$now = dol_now(); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +print load_fiche_titre($langs->trans('CashDeskRefNumberingModules'),'',''); + +print ''; +print ''; +print '\n"; +print '\n"; +print '\n"; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/takepos/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 16) == 'mod_takepos_ref_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file; + + // 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()) + { + $var=!$var; + print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; + + // example for next value + $invoice = new Facture($db); + $invoice->date = $now; + $invoice->module_source = 'takepos'; + $invoice->pos_source = 1; + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc, $invoice); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } +} +print "
'.$langs->trans("Name")."'.$langs->trans("Description")."'.$langs->trans("Example")."'.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->TAKEPOS_REF_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print '

\n"; // Mode print '
'; @@ -249,61 +373,61 @@ print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, 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 $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/invoice.php b/htdocs/takepos/invoice.php index 2c37d16f982..6ccc845d063 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -168,12 +168,12 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice->update($user); } - $sav_FACTURE_ADDON = ''; - if (!empty($conf->global->TAKEPOS_ADDON)) { - $sav_FACTURE_ADDON = $conf->global->FACTURE_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; - } +// $sav_FACTURE_ADDON = ''; +// if (!empty($conf->global->TAKEPOS_ADDON)) { +// $sav_FACTURE_ADDON = $conf->global->FACTURE_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"]; if ($invoice->statut != Facture::STATUS_DRAFT) { @@ -211,10 +211,10 @@ if ($action == 'valid' && $user->rights->facture->creer) } // Restore save values - if (!empty($sav_FACTURE_ADDON)) - { - $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; - } +// if (!empty($sav_FACTURE_ADDON)) +// { +// $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; +// } $remaintopay = $invoice->getRemainToPay();