Module TakePos - NEW add numbering module for cash desk

This commit is contained in:
VESSILLER 2020-03-12 17:43:59 +01:00
parent 69931efb6c
commit 70ebc61c1f
8 changed files with 685 additions and 114 deletions

View File

@ -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 '';
}
}

View File

@ -0,0 +1,175 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Open-DSI <support@open-dsi.fr>
*
* 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 <http://www.gnu.org/licenses/>.
* 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);
}
}

View File

@ -0,0 +1,146 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Open-DSI <support@open-dsi.fr>
*
* 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 <http://www.gnu.org/licenses/>.
* 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') . "<br>\n";
$texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
$texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconst" value="TAKEPOS_REF_UNIVERSAL_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$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 .= '<tr><td>' . $langs->trans("Mask") . ':</td>';
$texte .= '<td align="right">' . $form->textwithpicto('<input type="text" class="flat" size="24" name="maskvalue" value="' . $conf->global->TAKEPOS_REF_UNIVERSAL_MASK . '">', $tooltip, 1, 1) . '</td>';
$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button"></td>';
$texte .= '</tr>';
$texte .= '</table>';
$texte .= '</form>';
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);
}
}

View File

@ -0,0 +1,111 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2020 Open-DSI <support@open-dsi.fr>
*
* 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 <http://www.gnu.org/licenses/>.
* 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');
}
}

View File

@ -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 = <br><b>{TN}</b> tag is used to add the terminal number

View File

@ -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 = <br>La balise <b>{TN}</b> permet de rajouter le numéro du terminal

View File

@ -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 '<br>';
// Numbering modules
$now = dol_now();
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
print load_fiche_titre($langs->trans('CashDeskRefNumberingModules'),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name")."</td>\n";
print '<td>'.$langs->trans("Description")."</td>\n";
print '<td class="nowrap">'.$langs->trans("Example")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
print '</tr>'."\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 '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering module
print '<td class="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->TAKEPOS_REF_ADDON == "$file")
{
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setrefmod&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
print '</td>';
// 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").': <b>'.$module->getVersion().'</b><br>';
$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.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
}
}
closedir($handle);
}
}
}
print "</table><br>\n";
// Mode
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -249,61 +373,61 @@ print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename,
print "</td></tr>\n";
// Numbering module
print '<tr class="oddeven"><td>';
print $langs->trans("BillsNumberingModule");
print '<td colspan="2">';
$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 "</td></tr>\n";
//print '<tr class="oddeven"><td>';
//print $langs->trans("BillsNumberingModule");
//print '<td colspan="2">';
//$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 "</td></tr>\n";
print '</table>';
print '</div>';

View File

@ -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();