Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2017-11-11 17:49:51 +01:00
commit b5d63de708
18 changed files with 289 additions and 46 deletions

View File

@ -77,11 +77,6 @@ $model_option = array (
'label' => 'ACCOUNTING_EXPORT_DATE',
'param' => '',
),
//'ACCOUNTING_EXPORT_PIECE',
//'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT',
//'ACCOUNTING_EXPORT_LABEL',
//'ACCOUNTING_EXPORT_AMOUNT',
//'ACCOUNTING_EXPORT_DEVISE',
);
/*
@ -143,7 +138,6 @@ $form = new Form($db);
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
$head = admin_accounting_prepare_head();
print "\n".'<script type="text/javascript" language="javascript">'."\n";
print 'jQuery(document).ready(function () {'."\n";
@ -193,7 +187,6 @@ print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'technic');
/*
* Main Options

View File

@ -547,9 +547,9 @@ class AccountancyExport
$tab = array();
// export configurable
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
$tab[] = $line->piece_num;
$tab[] = $date;
$tab[] = $line->doc_ref;
$tab[] = $line->piece_num;
$tab[] = $line->label_operation;
$tab[] = length_accountg($line->numero_compte);
$tab[] = length_accounta($line->subledger_account);

View File

@ -80,6 +80,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
$search_country_id = GETPOST('search_country_id','int');
if($search_country_id == '') $search_country_id = $mysoc->country_id;
$search_code = GETPOST('search_code','alpha');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context

View File

@ -208,6 +208,68 @@ class Setup extends DolibarrApi
return $this->_cleanObjectDatas($country);
}
/**
* Get the list of delivery times.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number {@min 0}
* @param int $active Delivery times is active or not {@min 0} {@max 1}
* @param string $sqlfilters SQL criteria to filter with.
*
* @url GET dictionary/availability
*
* @return array [List of availability]
*
* @throws 400 RestException
* @throws 200 OK
*/
function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_availability as t";
$sql.= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
}
return $list;
}
/**
* Clean sensible object datas
*

View File

@ -6,6 +6,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Frédéric France <frederic.france@netlogic.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
@ -107,7 +108,8 @@ class FactureRec extends CommonInvoice
$this->nb_gen_done=0;
$this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max;
$this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate;
$this->generate_pdf = empty($this->generate_pdf)?0:$this->generate_pdf;
$this->db->begin();
// Charge facture modele
@ -127,6 +129,7 @@ class FactureRec extends CommonInvoice
$sql.= ", remise";
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", modelpdf";
$sql.= ", fk_user_author";
$sql.= ", fk_projet";
$sql.= ", fk_account";
@ -140,6 +143,7 @@ class FactureRec extends CommonInvoice
$sql.= ", nb_gen_done";
$sql.= ", nb_gen_max";
$sql.= ", auto_validate";
$sql.= ", generate_pdf";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->titre)."'";
$sql.= ", ".$facsrc->socid;
@ -149,6 +153,7 @@ class FactureRec extends CommonInvoice
$sql.= ", ".(!empty($facsrc->remise)?$this->remise:'0');
$sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
$sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql.= ", ".(!empty($this->modelpdf)?("'".$this->db->escape($this->modelpdf)."'"):"NULL");
$sql.= ", '".$this->db->escape($user->id)."'";
$sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null");
$sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null");
@ -162,6 +167,7 @@ class FactureRec extends CommonInvoice
$sql.= ", ".$this->nb_gen_done;
$sql.= ", ".$this->nb_gen_max;
$sql.= ", ".$this->auto_validate;
$sql.= ", ".$this->generate_pdf;
$sql.= ")";
if ($this->db->query($sql))
@ -276,9 +282,11 @@ class FactureRec extends CommonInvoice
$sql.= ', f.remise_percent, f.remise_absolue, f.remise';
$sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.note_private, f.note_public, f.fk_user_author';
$sql.= ', f.modelpdf';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
$sql.= ', f.fk_account';
$sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate';
$sql.= ', f.generate_pdf';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
//$sql.= ', el.fk_source';
@ -336,7 +344,7 @@ class FactureRec extends CommonInvoice
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->modelpdf = $obj->model_pdf;
$this->modelpdf = $obj->modelpdf;
$this->rang = $obj->rang;
$this->special_code = $obj->special_code;
$this->frequency = $obj->frequency;
@ -347,7 +355,8 @@ class FactureRec extends CommonInvoice
$this->nb_gen_max = $obj->nb_gen_max;
$this->usenewprice = $obj->usenewprice;
$this->auto_validate = $obj->auto_validate;
$this->generate_pdf = $obj->generate_pdf;
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty
@ -948,8 +957,18 @@ class FactureRec extends CommonInvoice
$this->errors = $facture->errors;
$this->error = $facture->error;
$error++;
}
}
}
if (! $error && $facturerec->generate_pdf)
{
$result = $facture->generateDocument($facturerec->modelpdf, $langs);
if ($result <= 0)
{
$this->errors = $facture->errors;
$this->error = $facture->error;
$error++;
}
}
if (! $error && $invoiceidgenerated >= 0)
{
@ -1391,6 +1410,68 @@ class FactureRec extends CommonInvoice
return -1;
}
}
/**
* Update the auto generate documents
*
* @param int $validate 0 no document, 1 to generate document
* @return int <0 if KO, >0 if OK
*/
function setGeneratePdf($validate)
{
if (! $this->table_element)
{
dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined",LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' SET generate_pdf = '.$validate;
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG);
if ($this->db->query($sql))
{
$this->generate_pdf = $validate;
return 1;
}
else
{
dol_print_error($this->db);
return -1;
}
}
/**
* Update the model for documents
*
* @param string $model model of document generator
* @return int <0 if KO, >0 if OK
*/
function setModelPdf($model)
{
if (! $this->table_element)
{
dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined",LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' SET modelpdf = "' . $model . '"';
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG);
if ($this->db->query($sql))
{
$this->modelpdf = $model;
return 1;
}
else
{
dol_print_error($this->db);
return -1;
}
}
}

View File

@ -8,6 +8,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017 Frédéric France <frederic.france@netlogic.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
@ -210,14 +211,15 @@ if (empty($reshook))
{
$object->titre = GETPOST('titre', 'alpha');
$object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public','none');
$object->note_public = GETPOST('note_public','none');
$object->modelpdf = GETPOST('modelpdf', 'alpha');
$object->usenewprice = GETPOST('usenewprice');
$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int');
$object->generate_pdf = GETPOST('generate_pdf', 'int');
$object->fk_project = $projectid;
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
@ -345,6 +347,16 @@ if (empty($reshook))
elseif ($action == 'setauto_validate' && $user->rights->facture->creer)
{
$object->setAutoValidate(GETPOST('auto_validate', 'int'));
}
// Set generate pdf
elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer)
{
$object->setGeneratepdf(GETPOST('generate_pdf', 'int'));
}
// Set model pdf
elseif ($action == 'setmodelpdf' && $user->rights->facture->creer)
{
$object->setModelpdf(GETPOST('modelpdf', 'alpha'));
}
// Delete line
@ -1040,6 +1052,13 @@ if ($action == 'create')
print "</td></tr>";
}
// Model pdf
print "<tr><td>".$langs->trans('Model')."</td><td>";
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
$list = ModelePDFFactures::liste_modeles($db);
print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
print "</td></tr>";
print "</table>";
dol_fiche_end();
@ -1075,6 +1094,12 @@ if ($action == 'create')
print $form->selectarray('auto_validate', $select, GETPOST('auto_validate'));
print "</td></tr>";
// Auto generate document
print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
$select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc'));
print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
print "</td></tr>";
print "</table>";
dol_fiche_end();
@ -1345,6 +1370,34 @@ else
print "</td>";
print '</tr>';
// Model pdf
$langs->load('banks');
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('Model');
print '<td>';
if (($action != 'editmodelpdf') && $user->rights->facture->creer && ! empty($object->brouillon))
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&amp;id='.$object->id.'">'.img_edit($langs->trans('SetModel'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editmodelpdf')
{
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
$list = array();
$models = ModelePDFFactures::liste_modeles($db);
foreach ($models as $model) {
$list[] = $model . ':' . $model;
}
$select = 'select;'.implode(',', $list);
print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select);
}
else
{
print $object->modelpdf;
}
print "</td>";
print '</tr>';
// Other attributes
$cols = 2;
@ -1449,12 +1502,25 @@ else
else
print $langs->trans("StatusOfGeneratedInvoices");
print '</td><td>';
$select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated');
$select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated');
if ($action == 'auto_validate' || $object->frequency > 0)
{
print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select);
}
print '</td>';
// Auto generate documents
print '<tr><td>';
if ($action == 'generate_pdf' || $object->frequency > 0)
print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
else
print $langs->trans("StatusOfGeneratedDocuments");
print '</td><td>';
$select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
if ($action == 'generate_pdf' || $object->frequency > 0)
{
print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
}
print '</td>';
print '</tr>';
print '</table>';

View File

@ -1579,6 +1579,12 @@ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='')
$ret.="\n".$object->state;
}
}
else if (in_array($object->country_code,array('IT'))) // IT: tile firstname name\n address lines \n zip (Code Departement) \n country
{
$ret .= ($ret ? $sep : '' ).$object->zip;
$ret .= ($object->town?(($object->zip?' ':'').$object->town):'');
$ret .= ($object->departement_id?(' ('.($object->departement_id).')'):'');
}
else // Other: title firstname name \n address lines \n zip town \n country
{
$ret .= $object->zip ? (($ret ? $sep : '' ).$object->zip) : '';

View File

@ -390,8 +390,10 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO deprecated
if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id);
if (! empty($sourcecompany->state_id) && !isset($sourcecompany->departement_id)) $sourcecompany->departement_id=getState($sourcecompany->state_id,'2');
if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id); //TODO deprecated
if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id);
if (! empty($targetcompany->state_id) && !isset($targetcompany->departement_id)) $targetcompany->departement_id=getState($targetcompany->state_id,'2');
$reshook=0;
$stringaddress = '';

View File

@ -456,7 +456,7 @@ function getRandomPassword($generic=false)
$randomCode = "";
$nbofchar = round($length/3);
$nbofcharlast = ($length - 2*$nbofchar);
var_dump($nbofchar.'-'.$nbofcharlast);
//var_dump($nbofchar.'-'.$nbofcharlast);
if (function_exists('random_int')) // Cryptographic random
{
$max = strlen($lowercase) - 1;

View File

@ -432,7 +432,7 @@ class ProductFournisseur extends Product
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
{
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($this->fk_product, $this->fk_supplier_price_expression, $this->fourn_qty, $this->fourn_tva_tx);
$price_result = $priceparser->parseProductSupplier($this);
if ($price_result >= 0) {
$this->fourn_price = $price_result;
//recalculation of unitprice, as probably the price changed...

View File

@ -528,6 +528,9 @@ ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity);
ALTER TABLE llx_product ADD COLUMN accountancy_code_sell_intra varchar(32) AFTER accountancy_code_sell;
ALTER TABLE llx_product ADD COLUMN accountancy_code_sell_export varchar(32) AFTER accountancy_code_sell_intra;
ALTER TABLE llx_facture_rec ADD COLUMN modelpdf varchar(255) AFTER note_public;
ALTER TABLE llx_facture_rec ADD COLUMN generate_pdf integer DEFAULT 0 AFTER auto_validate;
-- SPEC : use database type 'double' to store monetary values
ALTER TABLE llx_blockedlog MODIFY COLUMN amounts double(24,8);
ALTER TABLE llx_chargessociales MODIFY COLUMN amount double(24,8);

View File

@ -54,6 +54,7 @@ create table llx_facture_rec
fk_account integer, -- bank account id
note_private text,
note_public text,
modelpdf varchar(255),
fk_multicurrency integer,
multicurrency_code varchar(255),
@ -70,5 +71,6 @@ create table llx_facture_rec
date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice)
nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented)
nb_gen_max integer DEFAULT NULL, -- maximum number of generation
auto_validate integer DEFAULT 0 -- 0 to create in draft, 1 to create and validate the new invoice
auto_validate integer DEFAULT 0, -- 0 to create in draft, 1 to create and validate the new invoice
generate_pdf integer DEFAULT 0 -- 0 disable pdf, 1 to generate pdf
)ENGINE=innodb;

View File

@ -512,3 +512,5 @@ DeleteRepeatableInvoice=Delete template invoice
ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice?
CreateOneBillByThird=Create one invoice per third party (otherwise, one invoice per order)
BillCreated=%s bill(s) created
StatusOfGeneratedDocuments=Status of document generation
AutogenerateDoc=Auto generate document

View File

@ -155,6 +155,7 @@ ErrorPriceExpression19=Expression not found
ErrorPriceExpression20=Empty expression
ErrorPriceExpression21=Empty result '%s'
ErrorPriceExpression22=Negative result '%s'
ErrorPriceExpression23=Unknown or non set variable '%s' in %s
ErrorPriceExpressionInternal=Internal error '%s'
ErrorPriceExpressionUnknown=Unknown error '%s'
ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs

View File

@ -74,7 +74,7 @@ class PriceExpression
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -121,11 +121,18 @@ class PriceExpression
*/
function fetch($id)
{
// Check parameters
if (empty($id))
{
$this->error='ErrorWrongParameters';
return -1;
}
$sql = "SELECT title, expression";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch");
dol_syslog(__METHOD__);
$resql=$this->db->query($sql);
if ($resql)
{
@ -160,7 +167,7 @@ class PriceExpression
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " ORDER BY title";
dol_syslog(get_class($this)."::list_price_expression");
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -198,7 +205,7 @@ class PriceExpression
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE title = '".$this->db->escape($title)."'";
dol_syslog(get_class($this)."::find_title");
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -243,7 +250,7 @@ class PriceExpression
$this->db->begin();
dol_syslog(get_class($this)."::update");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -266,7 +273,7 @@ class PriceExpression
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
@ -314,7 +321,7 @@ class PriceExpression
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
}
@ -324,7 +331,7 @@ class PriceExpression
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();

View File

@ -74,7 +74,7 @@ class PriceGlobalVariable
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(__METHOD__);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -125,7 +125,7 @@ class PriceGlobalVariable
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch");
dol_syslog(__METHOD__);
$resql=$this->db->query($sql);
if ($resql)
{
@ -173,7 +173,7 @@ class PriceGlobalVariable
$this->db->begin();
dol_syslog(get_class($this)."::update");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -196,7 +196,7 @@ class PriceGlobalVariable
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
@ -243,7 +243,7 @@ class PriceGlobalVariable
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
}
@ -253,7 +253,7 @@ class PriceGlobalVariable
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
@ -306,7 +306,7 @@ class PriceGlobalVariable
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " ORDER BY code";
dol_syslog(get_class($this)."::listGlobalVariables");
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -84,7 +84,7 @@ class PriceGlobalVariableUpdater
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -135,7 +135,7 @@ class PriceGlobalVariableUpdater
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch");
dol_syslog(__METHOD__);
$resql=$this->db->query($sql);
if ($resql)
{
@ -191,7 +191,7 @@ class PriceGlobalVariableUpdater
$this->db->begin();
dol_syslog(get_class($this)."::update");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -260,7 +260,7 @@ class PriceGlobalVariableUpdater
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
}
@ -270,7 +270,7 @@ class PriceGlobalVariableUpdater
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
@ -346,7 +346,7 @@ class PriceGlobalVariableUpdater
$sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
dol_syslog(get_class($this)."::listUpdaters");
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -388,7 +388,7 @@ class PriceGlobalVariableUpdater
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE next_update < ".dol_now();
dol_syslog(get_class($this)."::processUpdaters");
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -428,6 +428,7 @@ class PriceGlobalVariableUpdater
{
global $langs, $user;
$langs->load("errors");
dol_syslog(__METHOD__, LOG_DEBUG);
$this->error = null;
$this->checkParameters();
@ -551,7 +552,7 @@ class PriceGlobalVariableUpdater
$this->db->begin();
dol_syslog(get_class($this)."::update_next_update");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -560,7 +561,7 @@ class PriceGlobalVariableUpdater
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update_next_update ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
@ -595,7 +596,7 @@ class PriceGlobalVariableUpdater
$this->db->begin();
dol_syslog(get_class($this)."::update_status");
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
@ -604,7 +605,7 @@ class PriceGlobalVariableUpdater
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update_status ".$errmsg, LOG_ERR);
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();

View File

@ -85,6 +85,7 @@ class PriceParser
-2 Args
6, wrong number of arguments (%s given, %s expected)
23, unknown or non set variable '%s' after %s
-internal errors
7, internal error
@ -178,19 +179,34 @@ class PriceParser
$values["global_".$entry->code] = $entry->value;
}
//Remove internal variables
unset($values["supplier_id"]);
//Prepare the lib, parameters and values
$em = new EvalMath();
$em->suppress_errors = true; //Don't print errors on page
$this->error_expr = null;
$last_result = null;
//Iterate over each expression splitted by $separator_chr
//Fill each variable in expression from values
$expression = str_replace("\n", $this->separator_chr, $expression);
foreach ($values as $key => $value)
{
if ($value === null) $value = "NULL";
$expression = str_replace($this->special_chr.$key.$this->special_chr, strval($value), $expression);
}
//Check if there is unfilled variable
if (strpos($expression, $this->special_chr) !== false)
{
$data = explode($this->special_chr, $expression);
$variable = $this->special_chr.$data[1];
if (isset($data[2])) $variable.= $this->special_chr;
$this->error_parser = array(23, array($variable, $expression));
return -6;
}
//Iterate over each expression splitted by $separator_chr
$expressions = explode($this->separator_chr, $expression);
$expressions = array_slice($expressions, 0, $this->limit);
foreach ($expressions as $expr) {
@ -241,7 +257,7 @@ class PriceParser
//Get the supplier min
$productFournisseur = new ProductFournisseur($this->db);
$supplier_min_price = $productFournisseur->find_min_price_product_fournisseur($product->id);
$supplier_min_price = $productFournisseur->find_min_price_product_fournisseur($product->id, 0, 0);
//Accessible values by expressions
$extra_values = array_merge($extra_values, array(