Issue #3509: Init works
This commit is contained in:
parent
f14c806439
commit
4fa1be0e35
219
htdocs/admin/payment.php
Normal file
219
htdocs/admin/payment.php
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/admin/payment.php
|
||||||
|
* \ingroup facture
|
||||||
|
* \brief Page to setup invoices payments
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
|
|
||||||
|
$langs->load("admin");
|
||||||
|
$langs->load("errors");
|
||||||
|
$langs->load('other');
|
||||||
|
$langs->load('bills');
|
||||||
|
|
||||||
|
if (! $user->admin) accessforbidden();
|
||||||
|
|
||||||
|
$action = GETPOST('action','alpha');
|
||||||
|
$value = GETPOST('value','alpha');
|
||||||
|
$label = GETPOST('label','alpha');
|
||||||
|
$scandir = GETPOST('scandir','alpha');
|
||||||
|
$type='invoice';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($action == 'updateMask')
|
||||||
|
{
|
||||||
|
$maskconstpayment=GETPOST('maskconstpayment','alpha');
|
||||||
|
$maskpayment=GETPOST('maskpayment','alpha');
|
||||||
|
if ($maskconstpayment) $res = dolibarr_set_const($db,$maskconstpayment,$maskpayment,'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
|
if (! $res > 0) $error++;
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("Error"),'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setmod')
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||||
|
|
||||||
|
llxHeader("",$langs->trans("BillsSetup"),'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura');
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
|
|
||||||
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
|
print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup');
|
||||||
|
|
||||||
|
$head = invoice_admin_prepare_head();
|
||||||
|
dol_fiche_head($head, 'payment', $langs->trans("Invoices"), 0, 'invoice');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Numbering module
|
||||||
|
*/
|
||||||
|
|
||||||
|
print load_fiche_titre($langs->trans("PaymentsNumberingModule"));
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("Name").'</td>';
|
||||||
|
print '<td>'.$langs->trans("Description").'</td>';
|
||||||
|
print '<td class="nowrap">'.$langs->trans("Example").'</td>';
|
||||||
|
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/payment/");
|
||||||
|
if (is_dir($dir))
|
||||||
|
{
|
||||||
|
$handle = opendir($dir);
|
||||||
|
if (is_resource($handle))
|
||||||
|
{
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
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_payment_".$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')
|
||||||
|
{
|
||||||
|
// Chargement de la classe de numerotation
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
$var = !$var;
|
||||||
|
print '<tr '.$bc[$var].'><td width="100">';
|
||||||
|
echo preg_replace('/\-.*$/','',preg_replace('/mod_payment_/','',preg_replace('/\.php$/','',$file)));
|
||||||
|
print "</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">';
|
||||||
|
//print "> ".$conf->global->PAYMENT_ADDON." - ".$file;
|
||||||
|
if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file)
|
||||||
|
{
|
||||||
|
print img_picto($langs->trans("Activated"),'switch_on');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/','',$file).'&scandir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$payment=new Paiement($db);
|
||||||
|
$payment->initAsSpecimen();
|
||||||
|
|
||||||
|
// Example
|
||||||
|
$htmltooltip='';
|
||||||
|
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||||
|
$nextval=$module->getNextValue($mysoc,$payment);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors
|
||||||
|
{
|
||||||
|
if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1);
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
@ -4,7 +4,8 @@
|
|||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
|
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -777,6 +778,30 @@ class Paiement extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise an instance with random values.
|
||||||
|
* Used to build previews or test instances.
|
||||||
|
* id must be 0 if object instance is a specimen.
|
||||||
|
*
|
||||||
|
* @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function initAsSpecimen($option='')
|
||||||
|
{
|
||||||
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
$arraynow=dol_getdate($now);
|
||||||
|
$nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
|
||||||
|
|
||||||
|
// Initialize parameters
|
||||||
|
$this->id=0;
|
||||||
|
$this->ref = 'SPECIMEN';
|
||||||
|
$this->specimen=1;
|
||||||
|
$this->facid = 1;
|
||||||
|
$this->datepaye = $nownotime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return clicable name (with picto eventually)
|
* Return clicable name (with picto eventually)
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -120,6 +121,11 @@ function invoice_admin_prepare_head()
|
|||||||
$head[$h][2] = 'general';
|
$head[$h][2] = 'general';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/admin/payment.php';
|
||||||
|
$head[$h][1] = $langs->trans("Payments");
|
||||||
|
$head[$h][2] = 'payment';
|
||||||
|
$h++;
|
||||||
|
|
||||||
// Show more tabs from modules
|
// Show more tabs from modules
|
||||||
// Entries must be declared in modules descriptor with line
|
// Entries must be declared in modules descriptor with line
|
||||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
|||||||
@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage customer order numbering rules Saphir
|
* Class to manage customer payment numbering rules Ant
|
||||||
*/
|
*/
|
||||||
class mod_payment_ant extends ModeleNumRefPayments
|
class mod_payment_ant extends ModeleNumRefPayments
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ class mod_payment_ant extends ModeleNumRefPayments
|
|||||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
$texte.= '<input type="hidden" name="action" value="updateMask">';
|
$texte.= '<input type="hidden" name="action" value="updateMask">';
|
||||||
$texte.= '<input type="hidden" name="maskconstorder" value="PAYMENT_ANT_MASK">';
|
$texte.= '<input type="hidden" name="maskconstpayment" value="PAYMENT_ANT_MASK">';
|
||||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||||
|
|
||||||
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
|
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
|
||||||
@ -63,7 +63,7 @@ class mod_payment_ant extends ModeleNumRefPayments
|
|||||||
|
|
||||||
// Parametrage du prefix
|
// Parametrage du prefix
|
||||||
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
|
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||||
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>';
|
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">',$tooltip,1,1).'</td>';
|
||||||
|
|
||||||
$texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
$texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class mod_payment_ant extends ModeleNumRefPayments
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$numFinal=get_next_value($db,$mask,'payment','ref','',$objsoc,$object->date);
|
$numFinal=get_next_value($db,$mask,'paiement','ref','',$objsoc,$object->date);
|
||||||
|
|
||||||
return $numFinal;
|
return $numFinal;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,9 @@
|
|||||||
require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
|
require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage customer order numbering rules Marbre
|
* Class to manage customer payment numbering rules Cicada
|
||||||
*/
|
*/
|
||||||
class mod_commande_cicada extends ModeleNumRefPayments
|
class mod_payment_cicada extends ModeleNumRefPayments
|
||||||
{
|
{
|
||||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
var $prefix='PAY';
|
var $prefix='PAY';
|
||||||
@ -72,7 +72,7 @@ class mod_commande_cicada extends ModeleNumRefPayments
|
|||||||
|
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment";
|
$sql.= " FROM ".MAIN_DB_PREFIX."paiement";
|
||||||
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
|
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class mod_commande_cicada extends ModeleNumRefPayments
|
|||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment";
|
$sql.= " FROM ".MAIN_DB_PREFIX."paiement";
|
||||||
$sql.= " WHERE ref like '".$this->prefix."____-%'";
|
$sql.= " WHERE ref like '".$this->prefix."____-%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
|
|||||||
@ -1179,6 +1179,7 @@ SuggestPaymentByRIBOnAccount=Suggest payment by withdraw on account
|
|||||||
SuggestPaymentByChequeToAddress=Suggest payment by cheque to
|
SuggestPaymentByChequeToAddress=Suggest payment by cheque to
|
||||||
FreeLegalTextOnInvoices=Free text on invoices
|
FreeLegalTextOnInvoices=Free text on invoices
|
||||||
WatermarkOnDraftInvoices=Watermark on draft invoices (none if empty)
|
WatermarkOnDraftInvoices=Watermark on draft invoices (none if empty)
|
||||||
|
PaymentsNumberingModule=Payments numbering model
|
||||||
##### Proposals #####
|
##### Proposals #####
|
||||||
PropalSetup=Commercial proposals module setup
|
PropalSetup=Commercial proposals module setup
|
||||||
CreateForm=Create forms
|
CreateForm=Create forms
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user