From 3036c94198d039e1ebc76c43928f3619d670172f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 7 Aug 2018 15:18:42 +0200 Subject: [PATCH 001/114] Add new situation retained warranty field --- htdocs/admin/facture_situation.php | 181 ++++++++++++++++++ htdocs/compta/facture/class/facture.class.php | 18 +- htdocs/core/lib/invoice.lib.php | 9 +- .../install/mysql/migration/8.0.0-9.0.0.sql | 5 + htdocs/install/mysql/tables/llx_facture.sql | 2 + htdocs/langs/en_US/bills.lang | 4 + 6 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 htdocs/admin/facture_situation.php diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php new file mode 100644 index 00000000000..cfee53da5f5 --- /dev/null +++ b/htdocs/admin/facture_situation.php @@ -0,0 +1,181 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2012-2013 Juanjo Menent + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * + * 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 . + */ + +/** + * \file htdocs/admin/facture.php + * \ingroup facture + * \brief Page to setup invoice module + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'errors', 'other', 'bills')); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scan_dir','alpha'); +$type='invoice'; + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + + +/* + * 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=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); + +$head = invoice_admin_prepare_head(); +dol_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice'); + +/* + * Numbering module + */ + +print load_fiche_titre($langs->trans("InvoiceSituation"),'',''); +$var=0; +print ''; + + +_print_on_off('INVOICE_USE_SITUATION',$langs->trans('UseSituationInvoices')); +_print_on_off('INVOICE_USE_SITUATION_CREDIT_NOTE',$langs->trans('UseSituationInvoicesCreditNote')); +_print_on_off('INVOICE_USE_SITUATION_RETAINED_WARANTY',$langs->trans('Retainedwarranty')); + +$metas = array( + 'type' => 'number', + 'step' => '0.01', + 'min' => 0, + 'max' => 100 +); +_print_input_form_part('INVOICE_SITUATION_DEFAULT_RETAINED_WARANTY_PERCENT',$langs->trans('RetainedwarrantyDefaultPercent'),'',$metas); + + + + +dol_fiche_end(); + +// End of page +llxFooter(); +$db->close(); + +function _print_on_off($confkey, $title = false, $desc ='') +{ + global $var, $bc, $langs, $conf; + $var=!$var; + + print ''; + print ''; + print ''; + print ''; +} + + +function _print_input_form_part($confkey, $title = false, $desc ='', $metas = array(), $type='input', $help = false) +{ + global $var, $bc, $langs, $conf, $db; + $var=!$var; + + $form=new Form($db); + + $defaultMetas = array( + 'name' => $confkey + ); + + if($type!='textarea'){ + $defaultMetas['type'] = 'text'; + $defaultMetas['value'] = $conf->global->{$confkey}; + } + + + $metas = array_merge ($defaultMetas, $metas); + $metascompil = ''; + foreach ($metas as $key => $values) + { + $metascompil .= ' '.$key.'="'.$values.'" '; + } + + print ''; + print ''; + print ''; + print ''; +} diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4edce36b82f..418339a0383 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -160,6 +160,9 @@ class Facture extends CommonInvoice public $tab_next_situation_invoice=array(); public $oldcopy; + + + public $retained_waranty; /** * Standard invoice @@ -339,6 +342,8 @@ class Facture extends CommonInvoice $this->note_public=trim($this->note_public); $this->note_private=trim($this->note_private); $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + + $this->retained_waranty = floatval($this->retained_waranty); $this->array_options=$_facrec->array_options; @@ -426,6 +431,7 @@ class Facture extends CommonInvoice $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; + $sql.= ", retained_waranty"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -458,6 +464,8 @@ class Facture extends CommonInvoice $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(empty($this->retained_waranty)?"0":$this->db->escape($this->retained_waranty)); + $sql.=")"; $resql=$this->db->query($sql); @@ -1276,6 +1284,7 @@ class Facture extends CommonInvoice $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ", i.libelle as libelle_incoterms"; + $sql.= ", f.retained_waranty as retained_waranty"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; @@ -1343,9 +1352,9 @@ class Facture extends CommonInvoice $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; + $this->retained_waranty = $obj->retained_waranty; $this->extraparams = (array) json_decode($obj->extraparams, true); - - //Incoterms + // Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; @@ -1569,7 +1578,9 @@ class Facture extends CommonInvoice if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); - + if (isset($this->retained_waranty)) $this->retained_waranty = floatval($this->retained_waranty); + + // Check parameters // Put here code to add control on parameters values @@ -1610,6 +1621,7 @@ class Facture extends CommonInvoice $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); + $sql.= " retained_waranty=".(empty($this->retained_waranty)?"0":$this->db->escape($this->retained_waranty)); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 4e7fa860529..c4ecbacf6e7 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -136,7 +136,14 @@ function invoice_admin_prepare_head() $head[$h][1] = $langs->trans("Payments"); $head[$h][2] = 'payment'; $h++; - + + if($conf->global->INVOICE_USE_SITUATION){ + $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; + $head[$h][1] = $langs->trans("InvoiceSituation"); + $head[$h][2] = 'situation'; + $h++; + } + // Show more tabs from modules // 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 diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index be072b8bacb..2a429fc7765 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -50,3 +50,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',204); ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after amount; + +ALTER TABLE llx_facture ADD COLUMN retained_waranty real DEFAULT NULL after situation_final; + + + diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index c0783a7bbd8..decd48f46bc 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -86,6 +86,8 @@ create table llx_facture situation_counter smallint, -- situation counter situation_final smallint, -- is the situation final ? + retained_waranty real DEFAULT NULL, -- % of retained warranty + import_key varchar(14), extraparams varchar(255), -- for other parameters with json format diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 54194358748..94f0786343e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -211,6 +211,10 @@ ShowInvoiceReplace=Show replacing invoice ShowInvoiceAvoir=Show credit note ShowInvoiceDeposit=Show down payment invoice ShowInvoiceSituation=Show situation invoice +UseSituationInvoices=Allow situation invoice +UseSituationInvoicesCreditNote=Allow situation invoice credit note +Retainedwarranty=Retained warranty +RetainedwarrantyDefaultPercent=Retained warranty default percent ShowPayment=Show payment AlreadyPaid=Already paid AlreadyPaidBack=Already paid back From 06be98c63855797f67508dec6177795e2cf5b177 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 8 Aug 2018 17:36:39 +0200 Subject: [PATCH 002/114] add date field --- htdocs/admin/facture_situation.php | 4 +- htdocs/compta/facture/card.php | 96 ++++++++++++++++ htdocs/compta/facture/class/facture.class.php | 104 ++++++++++++++++-- .../install/mysql/migration/8.0.0-9.0.0.sql | 4 +- htdocs/install/mysql/tables/llx_facture.sql | 3 +- htdocs/langs/en_US/bills.lang | 2 + 6 files changed, 199 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index cfee53da5f5..ad6f858df20 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -81,7 +81,7 @@ print '
'.($title?$title:$langs->trans($confkey)); + if(!empty($desc)) + { + print '
'.$langs->trans($desc).''; + } + print '
 '; + print '
'; + print ''; + print ''; + print ajax_constantonoff($confkey); + print '
'; + print '
'; + + if(!empty($help)){ + print $form->textwithtooltip( ($title?$title:$langs->trans($confkey)) , $langs->trans($help),2,1,img_help(1,'')); + } + else { + print $title?$title:$langs->trans($confkey); + } + + if(!empty($desc)) + { + print '
'.$langs->trans($desc).''; + } + + print '
 '; + print '
'; + print ''; + print ''; + if($type=='textarea'){ + print ''; + } + else { + print ''; + } + + print ''; + print '
'; + print '
'; _print_on_off('INVOICE_USE_SITUATION',$langs->trans('UseSituationInvoices')); _print_on_off('INVOICE_USE_SITUATION_CREDIT_NOTE',$langs->trans('UseSituationInvoicesCreditNote')); -_print_on_off('INVOICE_USE_SITUATION_RETAINED_WARANTY',$langs->trans('Retainedwarranty')); +_print_on_off('INVOICE_USE_SITUATION_RETAINED_WARRANTY',$langs->trans('Retainedwarranty')); $metas = array( 'type' => 'number', @@ -89,7 +89,7 @@ $metas = array( 'min' => 0, 'max' => 100 ); -_print_input_form_part('INVOICE_SITUATION_DEFAULT_RETAINED_WARANTY_PERCENT',$langs->trans('RetainedwarrantyDefaultPercent'),'',$metas); +_print_input_form_part('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT',$langs->trans('RetainedwarrantyDefaultPercent'),'',$metas); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e411f8c5b1b..6415ef4cdcd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -288,6 +288,23 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } + + else if ($action == 'setretainedwarranty' && $user->rights->facture->creer) + { + $object->fetch($id); + $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) + { + $object->fetch($id); + $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); + } + // Multicurrency Code else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) { @@ -1152,6 +1169,7 @@ if (empty($reshook)) $object->situation_counter = 1; $object->situation_final = 0; $object->situation_cycle_ref = $object->newCycle(); + $object->retained_warranty = !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)?$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY:0; } $object->fetch_thirdparty(); @@ -3919,6 +3937,70 @@ else if ($id > 0 || ! empty($ref)) print ''; } + + if($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) + { + // Retained Warranty + print ''; + + + // Retained Warranty payment date limit + print ''; + } + + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -4360,6 +4442,20 @@ else if ($id > 0 || ! empty($ref)) // Billed print ''; + if(!empty($object->retained_warranty)){ + // Billed - retained warranty + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; + print ''; + + // retained warranty + print ''; + + } + // Remainder to pay print ''; print ''; print ''; - print ''; } function _print_input_form_part($confkey, $title = false, $desc ='', $metas = array(), $type='input', $help = false) { - global $var, $bc, $langs, $conf, $db; + global $var, $bc, $langs, $conf, $db, $inputCount; $var=!$var; - + $inputCount = empty($inputCount)?1:($inputCount+1); $form=new Form($db); $defaultMetas = array( - 'name' => $confkey + 'name' => 'value'.$inputCount ); if($type!='textarea'){ @@ -165,17 +190,14 @@ function _print_input_form_part($confkey, $title = false, $desc ='', $metas = ar print ''; print ''; print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6415ef4cdcd..c9e14304954 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -289,6 +289,21 @@ if (empty($reshook)) dol_print_error($db, $object->error); } + else if ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) + { + $object->fetch($id); + $object->retained_warranty_fk_cond_reglement = 0; // To clean property + $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); + if ($result < 0) dol_print_error($db, $object->error); + + $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; + $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; + if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); + } + else if ($action == 'setretainedwarranty' && $user->rights->facture->creer) { $object->fetch($id); @@ -877,7 +892,7 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - + // Proprietes particulieres a facture de remplacement $object->fk_facture_source = $_POST['fac_replacement']; $object->type = Facture::TYPE_REPLACEMENT; @@ -1163,13 +1178,25 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + + + if (GETPOST('type') == Facture::TYPE_SITUATION) { $object->situation_counter = 1; $object->situation_final = 0; $object->situation_cycle_ref = $object->newCycle(); - $object->retained_warranty = !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)?$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY:0; + + + $object->retained_warranty = GETPOST('retained_warranty', 'int'); + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){ + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); } $object->fetch_thirdparty(); @@ -1583,7 +1610,7 @@ if (empty($reshook)) $object->mode_reglement_id = GETPOST('mode_reglement_id','int'); $object->remise_absolue = GETPOST('remise_absolue','int'); $object->remise_percent = GETPOST('remise_percent','int'); - + // Proprietes particulieres a facture de remplacement $object->situation_counter = $object->situation_counter + 1; @@ -3082,6 +3109,44 @@ if ($action == 'create') print ''; + + if (! empty($conf->global->INVOICE_USE_SITUATION)) + { + if($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY){ + + $rwStyle = 'display:none;'; + if(GETPOST('type', 'int') == Facture::TYPE_SITUATION){ + $rwStyle = ''; + } + + + $retained_warranty = GETPOST('retained_warranty', 'int'); + $retained_warranty = !empty($retained_warranty)?$retained_warranty:$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; + print ''; + + print ''; + } + } // Payment mode print ''; } - - if($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) + $displayWarranty = false; + if( !empty($object->situation_final) + && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) + ) { + // Check if this situation invoice is 100% for real + if(!empty($object->lines)){ + $displayWarranty = true; + foreach( $object->lines as $i => $line ){ + if($line->product_type < 2 && $line->situation_percent < 100){ + $displayWarranty = false; + break; + } + } + } + + + // Retained Warranty - print ''; - // Type + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; + + // Type print ''; print ''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; - // Date start subscription print '
'; + print ''; + if ($action != 'editretainedwarranty' && $user->rights->facture->creer){ + print ''; + } + + print '
'; + print $langs->trans('RetainedWarranty'); + print 'id . '">' . img_edit($langs->trans('setretainedwarranty'), 1) . '
'; + print '
'; + if ($action == 'editretainedwarranty') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } + else + { + print price($object->retained_warranty).'%'; + } + print '
'; + print ''; + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer){ + print ''; + } + + print '
'; + print $langs->trans('RetainedWarrantyDateLimit'); + print 'id . '">' . img_edit($langs->trans('setretainedwarrantyDateLimit'), 1) . '
'; + print '
'; + $defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement); + if($object->date > $defaultDate){ + $defaultDate = $object->date; + } + + if ($action == 'editretainedwarrantydatelimit') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } + else + { + print dol_print_date($defaultDate); + } + print '
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement)) . ' :' . price($billedWithRetainedWarranty) . ' 
'; + print $langs->trans("RetainedWarranty") . ' ('.$object->retained_warranty.'%)'; + print !empty($object->retained_warranty_date_limit)?' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit)):''; + print ' :' . price($retainedWarranty) . ' 
'; if ($resteapayeraffiche >= 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 418339a0383..9c387f6630a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -162,7 +162,9 @@ class Facture extends CommonInvoice public $oldcopy; - public $retained_waranty; + public $retained_warranty; + + public $retained_warranty_date_limit; /** * Standard invoice @@ -343,7 +345,7 @@ class Facture extends CommonInvoice $this->note_private=trim($this->note_private); $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->retained_waranty = floatval($this->retained_waranty); + $this->retained_warranty = floatval($this->retained_warranty); $this->array_options=$_facrec->array_options; @@ -431,7 +433,8 @@ class Facture extends CommonInvoice $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; - $sql.= ", retained_waranty"; + $sql.= ", retained_warranty"; + $sql.= ", retained_warranty_date_limit"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -464,7 +467,8 @@ class Facture extends CommonInvoice $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; - $sql.= ", ".(empty($this->retained_waranty)?"0":$this->db->escape($this->retained_waranty)); + $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); + $sql.= ", '".$this->db->idate($this->retained_warranty_date_limit)."'"; $sql.=")"; @@ -1284,7 +1288,7 @@ class Facture extends CommonInvoice $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ", i.libelle as libelle_incoterms"; - $sql.= ", f.retained_waranty as retained_waranty"; + $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; @@ -1352,7 +1356,9 @@ class Facture extends CommonInvoice $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; - $this->retained_waranty = $obj->retained_waranty; + $this->retained_warranty = $obj->retained_warranty; + $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); + $this->extraparams = (array) json_decode($obj->extraparams, true); // Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -1578,7 +1584,7 @@ class Facture extends CommonInvoice if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); - if (isset($this->retained_waranty)) $this->retained_waranty = floatval($this->retained_waranty); + if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); // Check parameters @@ -1620,8 +1626,9 @@ class Facture extends CommonInvoice $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)); - $sql.= " retained_waranty=".(empty($this->retained_waranty)?"0":$this->db->escape($this->retained_waranty)); + $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)).","; + $sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).","; + $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null'); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -4226,6 +4233,85 @@ class Facture extends CommonInvoice return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); } + + + /** + * Change the retained warranty + * + * @param float $value value of retained warranty + * @return int >0 if OK, <0 if KO + */ + function setRetainedWarranty($value) + { + dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')'); + if ($this->statut >= 0) + { + $fieldname = 'retained_warranty'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.floatval($value); + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->retained_warranty = floatval($value); + return 1; + } + else + { + dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } + + + /** + * Change the retained_warranty_date_limit + * + * @param timestamp $value value of retained warranty + * @return int >0 if OK, <0 if KO + */ + function setRetainedWarrantyDateLimit($timestamp,$dateYmd=false) + { + if(!$timestamp && $dateYmd){ + $timestamp = $this->db->jdate($dateYmd); + } + + + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$value.')'); + if ($this->statut >= 0) + { + $fieldname = 'retained_warranty_date_limit'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' ); + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->retained_warranty_date_limit = $timestamp; + return 1; + } + else + { + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } } /** diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 2a429fc7765..fb7db220138 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -51,7 +51,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after amount; -ALTER TABLE llx_facture ADD COLUMN retained_waranty real DEFAULT NULL after situation_final; - +ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index decd48f46bc..abdefedc944 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -86,7 +86,8 @@ create table llx_facture situation_counter smallint, -- situation counter situation_final smallint, -- is the situation final ? - retained_waranty real DEFAULT NULL, -- % of retained warranty + retained_warranty real DEFAULT NULL, -- % of retained warranty + retained_warranty_date_limit date DEFAULT NULL, import_key varchar(14), extraparams varchar(255), -- for other parameters with json format diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 94f0786343e..c547f385be0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -550,3 +550,5 @@ AutoFillDateFromShort=Set start date AutoFillDateTo=Set end date for service line with next invoice date AutoFillDateToShort=Set end date MaxNumberOfGenerationReached=Max number of gen. reached +ToPayOn=To pay on %s +RetainedWarranty=Retained Warranty From d6d8f98f38f01930958654f6d720f478c60c88b5 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 10 Aug 2018 15:06:00 +0200 Subject: [PATCH 003/114] add retained warranty cond field and add forms --- htdocs/admin/facture_situation.php | 54 ++++-- htdocs/compta/facture/card.php | 169 +++++++++++++++--- htdocs/compta/facture/class/facture.class.php | 23 ++- htdocs/core/class/commonobject.class.php | 37 ++++ .../install/mysql/migration/8.0.0-9.0.0.sql | 1 + htdocs/install/mysql/tables/llx_facture.sql | 5 +- htdocs/langs/en_US/bills.lang | 7 + 7 files changed, 248 insertions(+), 48 deletions(-) diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index ad6f858df20..dc3ec771b16 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -76,6 +76,12 @@ dol_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoi print load_fiche_titre($langs->trans("InvoiceSituation"),'',''); $var=0; + +print '
'; +print ''; + +_updateBtn(); + print ''; @@ -94,17 +100,40 @@ _print_input_form_part('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT',$la +// Conditions paiements +$inputCount = empty($inputCount)?1:($inputCount+1); +print ''; +print ''; +print ''; +print ''; + + +print '
'.$langs->trans('PaymentConditionsShortRetainedWarranty').' '; +print ''; +$form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1); +print '
'; + +_updateBtn(); + +print '
'; + dol_fiche_end(); // End of page llxFooter(); $db->close(); +function _updateBtn(){ + global $langs; + print '
'; + print ''; + print '
'; +} + function _print_on_off($confkey, $title = false, $desc ='') { - global $var, $bc, $langs, $conf; + global $var, $bc, $langs; $var=!$var; - print '
'.($title?$title:$langs->trans($confkey)); if(!empty($desc)) @@ -113,25 +142,21 @@ function _print_on_off($confkey, $title = false, $desc ='') } print ' '; - print '
'; - print ''; - print ''; + print '
'; print ajax_constantonoff($confkey); - print ''; print '
 '; - print '
'; - print ''; - print ''; + print ''; + + print ''; if($type=='textarea'){ print ''; } else { print ''; } - - print ''; - print '
'; print '
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
' . $langs->trans('RetainedWarranty') . ''; + print '%'; + + // Retained warranty payment term + print '
' . $langs->trans('PaymentConditionsShortRetainedWarranty') . ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement'); + print '
' . $langs->trans('PaymentMode') . ''; @@ -3937,12 +4002,27 @@ else if ($id > 0 || ! empty($ref)) print '
'; - print ''; } elseif ($key == "fk_soc") From dfc2bebbb6dd660eb8850755ad6e04f2ff55ac7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 13:27:07 +0200 Subject: [PATCH 092/114] FIX #11400 --- htdocs/accountancy/bookkeeping/card.php | 14 ++++++++--- .../class/accountancyexport.class.php | 24 ++++++------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 1f38171f199..0328eba010c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php $langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' @@ -346,6 +347,8 @@ if ($action == 'create') } print '
'; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -441,7 +444,8 @@ if ($action == 'create') print '
'; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } @@ -254,13 +252,13 @@ class FormMargin { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } @@ -268,13 +266,13 @@ class FormMargin { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; } print '
'; + print '
'; + print ''; if ($action != 'editretainedwarranty' && $user->rights->facture->creer){ @@ -3953,7 +4033,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - - // Retained Warranty payment date limit - print ''; - print ''; - print ''; - // Title - print ''; - print ''; + if (! empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + { + // Firstname + print ''; + print ''; + print ''; + + // Title + print ''; + print ''; + } } // Alias names (commercial, trademark or alias names) From 5b1a89bf94e066570ea3ca7b6000d183468b5e2f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 30 Jul 2019 11:55:46 +0200 Subject: [PATCH 072/114] Fix php error with const --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 61acf6e3a89..378d6087cc7 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ if ($action=="create" || $action=="start") } // Get the bank account dedicated to this point of sale module/terminal - $vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse; + $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here From a7a2e483c97e3682f4b8adb5cbd8013194793bd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 16:01:26 +0200 Subject: [PATCH 073/114] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index e48fe32e4f0..4f525330e79 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1683,7 +1683,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print ''; print ''; - print ''; + print ''; print ''; print ''; print "\n"; -print ''; -print ''; +print ''; @@ -134,23 +134,26 @@ $atleastonefound = 0; if (! empty($conf->banque->enabled)) { print ''; - print ''; print ''; - print ''; print ''; - print ''; foreach($paiements as $modep) { - if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; + if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; // Already managed before $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse; print ''; - print ''; // Force warehouse (this is not a default value) - print ''; // Force warehouse (this is not a default value) - print '
'; print $langs->trans('RetainedWarranty'); print ''; if ($action == 'editretainedwarranty') { - print '
'; + print ''; print ''; print ''; print ''; @@ -3966,14 +4046,13 @@ else if ($id > 0 || ! empty($ref)) } print '
'; - print ''; + + + + + if($displayWarranty) + { + // Retained Warranty payment date limit + print ''; + } + } @@ -4442,16 +4566,17 @@ else if ($id > 0 || ! empty($ref)) // Billed print ''; - if(!empty($object->retained_warranty)){ + // Retained warranty : usualy use on construction industry + if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){ // Billed - retained warranty $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; - print ''; + print ''; // retained warranty print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9c387f6630a..e108b526576 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -165,6 +165,8 @@ class Facture extends CommonInvoice public $retained_warranty; public $retained_warranty_date_limit; + + public $retained_warranty_fk_cond_reglement; /** * Standard invoice @@ -345,8 +347,8 @@ class Facture extends CommonInvoice $this->note_private=trim($this->note_private); $this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->retained_warranty = floatval($this->retained_warranty); + $this->array_options=$_facrec->array_options; //if (! $this->remise) $this->remise = 0; @@ -356,6 +358,7 @@ class Facture extends CommonInvoice $this->linked_objects = $_facrec->linkedObjectsIds; $forceduedate = $this->calculate_date_lim_reglement(); + // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice if ($_facrec->frequency > 0) @@ -407,7 +410,7 @@ class Facture extends CommonInvoice // Define due date if not already defined $datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); - + // Insert into database $socid = $this->socid; @@ -435,6 +438,7 @@ class Facture extends CommonInvoice $sql.= ", multicurrency_tx"; $sql.= ", retained_warranty"; $sql.= ", retained_warranty_date_limit"; + $sql.= ", retained_warranty_fk_cond_reglement"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -468,10 +472,11 @@ class Facture extends CommonInvoice $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); - $sql.= ", '".$this->db->idate($this->retained_warranty_date_limit)."'"; + $sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL'); + $sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement; $sql.=")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -1288,7 +1293,7 @@ class Facture extends CommonInvoice $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ", i.libelle as libelle_incoterms"; - $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit"; + $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; @@ -1356,8 +1361,9 @@ class Facture extends CommonInvoice $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; - $this->retained_warranty = $obj->retained_warranty; - $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); + $this->retained_warranty = $obj->retained_warranty; + $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); + $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; $this->extraparams = (array) json_decode($obj->extraparams, true); // Incoterms @@ -1628,7 +1634,8 @@ class Facture extends CommonInvoice $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter)).","; $sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).","; - $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null'); + $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').","; + $sql.= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement)?intval($this->retained_warranty_fk_cond_reglement):"null"); $sql.= " WHERE rowid=".$this->id; $this->db->begin(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5e528f6a1d0..37f61e01f32 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1906,6 +1906,43 @@ abstract class CommonObject return -2; } } + + /** + * Change the retained warranty payments terms + * + * @param int $id Id of new payment terms + * @return int >0 if OK, <0 if KO + */ + function setRetainedWarrantyPaymentTerms($id) + { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'retained_warranty_fk_cond_reglement'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->retained_warranty_fk_cond_reglement = $id; + return 1; + } + else + { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } /** * Define delivery address diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index fb7db220138..3eb266d3559 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -53,5 +53,6 @@ ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after a ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index abdefedc944..f18ec0f521c 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -86,8 +86,9 @@ create table llx_facture situation_counter smallint, -- situation counter situation_final smallint, -- is the situation final ? - retained_warranty real DEFAULT NULL, -- % of retained warranty - retained_warranty_date_limit date DEFAULT NULL, + retained_warranty real DEFAULT NULL, -- % of retained warranty + retained_warranty_date_limit date DEFAULT NULL, + retained_warranty_fk_cond_reglement integer DEFAULT NULL, -- payment condition of retained warranty import_key varchar(14), extraparams varchar(255), -- for other parameters with json format diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index c547f385be0..c9f966b2e2a 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -552,3 +552,10 @@ AutoFillDateToShort=Set end date MaxNumberOfGenerationReached=Max number of gen. reached ToPayOn=To pay on %s RetainedWarranty=Retained Warranty +PaymentConditionsShortRetainedWarranty=Retained warranty payment terms +DefaultPaymentConditionsRetainedWarranty=Default retained warranty payment terms +setPaymentConditionsShortRetainedWarranty=Set retained warranty payment terms +setretainedwarranty=Set retained warranty +setretainedwarrantyDateLimit=Set retained warranty date limit +RetainedWarrantyDateLimit=Retained warranty date limit +RetainedWarrantyNeed100Percent=The situation invoice need to be at 100%% progress to be displayed on PDF From 6fad0ea5bd07307efb56573714b377db3bde61a9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 10 Aug 2018 16:03:39 +0200 Subject: [PATCH 004/114] Add retained warranty to pdf --- htdocs/compta/facture/card.php | 2 +- .../modules/facture/doc/pdf_crabe.modules.php | 43 +++++++++++++++++++ htdocs/langs/en_US/bills.lang | 1 + 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c9e14304954..b1d1116e54c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4079,7 +4079,7 @@ else if ($id > 0 || ! empty($ref)) { print $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->retained_warranty_fk_cond_reglement, 'none'); if(!$displayWarranty){ - print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); } } print ''; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ba52759ea35..ad650aca9b4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1331,6 +1331,49 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); + + // Retained warranty + if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) ) + { + // Check if this situation invoice is 100% for real + if(!empty($object->lines)){ + $displayWarranty = true; + foreach( $object->lines as $i => $line ){ + if($line->product_type < 2 && $line->situation_percent < 100){ + $displayWarranty = false; + break; + } + } + } + + if($displayWarranty){ + $pdf->SetTextColor(40,40,40); + $pdf->SetFillColor(255,255,255); + + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; + + // Billed - retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty) , $useborder, 'R', 1); + + // retained warranty + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty") . ' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):''; + + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty) , $useborder, 'R', 1); + } + } + } } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index c9f966b2e2a..95c1a87172a 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -551,6 +551,7 @@ AutoFillDateTo=Set end date for service line with next invoice date AutoFillDateToShort=Set end date MaxNumberOfGenerationReached=Max number of gen. reached ToPayOn=To pay on %s +toPayOn=to pay on %s RetainedWarranty=Retained Warranty PaymentConditionsShortRetainedWarranty=Retained warranty payment terms DefaultPaymentConditionsRetainedWarranty=Default retained warranty payment terms From 681ae88e97b8b3155ccdf7ffbd5072a63961314e Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 10 Aug 2018 16:59:22 +0200 Subject: [PATCH 005/114] fix display cond --- htdocs/compta/facture/card.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b1d1116e54c..6f4796106c7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4001,14 +4001,12 @@ else if ($id > 0 || ! empty($ref)) } print ''; } - + $displayWarranty = false; - if( !empty($object->situation_final) - && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) - ) + if( ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) ) { // Check if this situation invoice is 100% for real - if(!empty($object->lines)){ + if(!empty($object->situation_final) && !empty($object->lines)){ $displayWarranty = true; foreach( $object->lines as $i => $line ){ if($line->product_type < 2 && $line->situation_percent < 100){ From 40369280ba330e9645d5e52835f212311e01883a Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 25 Sep 2018 12:16:16 +0200 Subject: [PATCH 006/114] fix allow empty selection on form conditions reglement --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6f4796106c7..4974bcb4a39 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3129,7 +3129,7 @@ if ($action == 'create') print ''; print ' + '; } if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe - print '
'; + print '
'; print '
'; print ''.$langs->trans("CreditOrDebitCard").''; print '
'; + print ' + '; } if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; - print '
'; + print '
'; if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') { print '
'; @@ -1718,6 +1743,19 @@ if ($action != 'dopayment') //print '
'.$langs->trans("PaypalAccount").'">'; } print '
'; + print ' + '; } } } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 58b076a953c..a137b91236f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -147,6 +147,9 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment { color: #fff; border-radius: 4px; } +div.buttonpayment input:focus { + color: #008; +} .buttonpaymentsmall { font-size: 0.65em; padding-left: 5px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9fad375eade..8999a73aaea 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -376,6 +376,9 @@ div.buttonpayment input { color: #333; cursor: pointer; } +div.buttonpayment input:focus { + color: #008; +} input.buttonpaymentcb { background-image: url(); background-size: 26px; From 9ca4d65965050e02a4afd746f06f2f323c656705 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 01:12:03 +0200 Subject: [PATCH 048/114] Fix stripe error management --- htdocs/public/payment/newpayment.php | 10 ++++++++-- htdocs/stripe/class/stripe.class.php | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 8c9eb93004f..02dc94285f6 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -430,7 +430,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) 'dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'dol_company' => $mysoc->name, // Usefull when using multicompany - 'dol_tax_num' => $taxinfo, + 'dol_tax_num' => $vatnumber, 'ipaddress'=> getUserRemoteIP() ); @@ -455,7 +455,13 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); $stripeacc = $stripe->getStripeAccount($service); - $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + if (empty($customer)) + { + $error++; + dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERROR, 0, '_stripe'); + setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors'); + } // Create Stripe card from Token if ($savesource) { diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6b910236e96..c731637fce6 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -177,6 +177,7 @@ class Stripe extends CommonObject } catch(Exception $e) { + // For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.' $this->error = $e->getMessage(); } } From 3112f2b1c564d549440cfbb63fb267237891b15f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 01:13:49 +0200 Subject: [PATCH 049/114] Fix error level --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 02dc94285f6..e43089f0a8d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -459,7 +459,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) if (empty($customer)) { $error++; - dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERROR, 0, '_stripe'); + dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERR, 0, '_stripe'); setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors'); } From 406375bfc444829764b844477a73a810ffb9248a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 01:17:53 +0200 Subject: [PATCH 050/114] Fix error management --- htdocs/public/payment/newpayment.php | 76 +++++++++++++++------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index e43089f0a8d..0a967cb10a7 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -461,47 +461,51 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) $error++; dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERR, 0, '_stripe'); setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors'); + $action=''; } // Create Stripe card from Token - if ($savesource) { - $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); - } else { - $card = $stripeToken; - } - - if (empty($card)) + if (! $error) { - $error++; - dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to create card record', null, 'errors'); - $action=''; - } - else - { - if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (! empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (! empty($dol_type)) $metadata["dol_type"] = $dol_type; + if ($savesource) { + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { + $card = $stripeToken; + } - dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'customer' => $customer->id, - 'source' => $card, - 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action=''; - } + if (empty($card)) + { + $error++; + dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to create card record', null, 'errors'); + $action=''; + } + else + { + if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (! empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (! empty($dol_type)) $metadata["dol_type"] = $dol_type; + + dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'customer' => $customer->id, + 'source' => $card, + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action=''; + } + } } } else From 79bb9d951f5a47c786200006a89177ccfce9b950 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 01:36:05 +0200 Subject: [PATCH 051/114] Fix phpcs --- htdocs/expensereport/class/expensereport.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 4cc935f95a2..2d9795e6f59 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1181,7 +1181,6 @@ class ExpenseReport extends CommonObject } } } - } } From ecc0b4ed32a13646fcfb277dbd5c1ef0531889b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 02:16:21 +0200 Subject: [PATCH 052/114] Add prefixsession in event table --- htdocs/admin/tools/listevents.php | 76 ++++++++++++++++++++++++------ htdocs/core/class/events.class.php | 34 +++++++++++-- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 39ed6162f0f..bcb727f1fcb 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -56,11 +56,12 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="dateevent"; if (! $sortorder) $sortorder="DESC"; -$search_code = GETPOST("search_code"); -$search_ip = GETPOST("search_ip"); -$search_user = GETPOST("search_user"); -$search_desc = GETPOST("search_desc"); -$search_ua = GETPOST("search_ua"); +$search_code = GETPOST("search_code", "alpha"); +$search_ip = GETPOST("search_ip", "alpha"); +$search_user = GETPOST("search_user", "alpha"); +$search_desc = GETPOST("search_desc", "alpha"); +$search_ua = GETPOST("search_ua", "none"); +$search_prefix_session = GETPOST("search_prefix_session", "none"); if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); else $date_start=-1; @@ -91,6 +92,8 @@ $date_endday = $tmp['mday']; $date_endmonth = $tmp['mon']; $date_endyear = $tmp['year']; +$arrayfields=array(); + /* * Actions @@ -108,6 +111,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_user=''; $search_desc=''; $search_ua=''; + $search_prefix_session=''; } // Purge audit events @@ -136,6 +140,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $securityevent->type='SECURITY_EVENTS_PURGE'; $securityevent->dateevent=$now; $securityevent->description=$text; + $result=$securityevent->create($user); if ($result > 0) { @@ -163,7 +168,7 @@ $userstatic=new User($db); $usefilter=0; $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,"; -$sql.= " e.fk_user, e.description,"; +$sql.= " e.fk_user, e.description, e.prefix_session,"; $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; @@ -175,6 +180,7 @@ if ($search_ip) { $usefilter++; $sql.=natural_search("e.ip", $search_ip, 0); } if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); } if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); } if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); } +if ($search_prefix_session) { $usefilter++; $sql.=natural_search("e.prefix_session", $search_prefix_session, 0); } $sql.= $db->order($sortfield, $sortorder); // Count total nb of records @@ -207,6 +213,7 @@ if ($result) if ($search_user) $param.='&search_user='.urlencode($search_user); if ($search_desc) $param.='&search_desc='.urlencode($search_desc); if ($search_ua) $param.='&search_ua='.urlencode($search_ua); + if ($search_prefix_sessiona) $param.='&search_prefix_session='.urlencode($search_prefix_session); if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth); if ($date_startday) $param.= "&date_startday=".urlencode($date_startday); if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear); @@ -239,22 +246,36 @@ if ($result) print '
'; print ''; // IP print ''; print ''; print ''; + if (! empty($arrayfields['e.user_agent']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + print ''; + } + print ''; - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, 'align="left"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['e.user_agent']['checked'])) + { + print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); + } print_liste_field_titre(''); print "\n"; @@ -312,9 +341,26 @@ if ($result) print $text; print ''; + if (! empty($arrayfields['e.user_agent']['checked'])) + { + // User agent + print ''; + } + + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + // User agent + print ''; + } + // More informations print ''; diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index af87e25fad1..57a076963fd 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -63,11 +63,20 @@ class Events // extends CommonObject public $dateevent; + public $ip; + + public $user_agent; + /** * @var string description */ public $description; + /** + * @var string Prefix session obtained with method dol_getprefix() + */ + public $prefix_session; + // List of all Audit/Security events supported by triggers public $eventstolog=array( array('id'=>'USER_LOGIN', 'test'=>1), @@ -108,6 +117,18 @@ class Events // extends CommonObject ); + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), + ); + + /** * Constructor * @@ -144,7 +165,8 @@ class Events // extends CommonObject $sql.= "user_agent,"; $sql.= "dateevent,"; $sql.= "fk_user,"; - $sql.= "description"; + $sql.= "description,"; + $sql.= "prefix_session"; $sql.= ") VALUES ("; $sql.= " '".$this->db->escape($this->type)."',"; $sql.= " ".$conf->entity.","; @@ -152,7 +174,8 @@ class Events // extends CommonObject $sql.= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; $sql.= " '".$this->db->idate($this->dateevent)."',"; $sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').","; - $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."'"; + $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; + $sql.= " '".$this->db->escape(dol_getprefix())."'"; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -222,7 +245,8 @@ class Events // extends CommonObject $sql.= " t.dateevent,"; $sql.= " t.description,"; $sql.= " t.ip,"; - $sql.= " t.user_agent"; + $sql.= " t.user_agent,"; + $sql.= " t.prefix_session"; $sql.= " FROM ".MAIN_DB_PREFIX."events as t"; $sql.= " WHERE t.rowid = ".$id; @@ -242,6 +266,7 @@ class Events // extends CommonObject $this->description = $obj->description; $this->ip = $obj->ip; $this->user_agent = $obj->user_agent; + $this->prefix_session = $obj->prefix_session; } $this->db->free($resql); @@ -293,5 +318,8 @@ class Events // extends CommonObject $this->type=''; $this->dateevent=time(); $this->description='This is a specimen event'; + $this->ip = '1.2.3.4'; + $this->user_agent = 'Mozilla specimen User Agent X.Y'; + $this->prefix_session = dol_getprefix(); } } From cd22cc70c8a307f4feda0cde338b7a799712fdb3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 06:41:51 +0200 Subject: [PATCH 053/114] FIX FEC Format - Save translation of the journal --- htdocs/accountancy/class/bookkeeping.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 21e43b524d7..67633e828a5 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -472,14 +472,15 @@ class BookKeeping extends CommonObject */ public function createStd(User $user, $notrigger = false, $mode='') { - global $conf; + global $conf, $langs; + + $langs->loadLangs(array("accountancy", "bills", "compta")); dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; // Clean parameters - if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -546,7 +547,7 @@ class BookKeeping extends CommonObject $now = dol_now(); // Check parameters - // Put here code to add control on parameters values + $this->journal_label = $langs->trans($this->journal_label); // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; From 7a9f2b43c508958104281304c6215446c93cc4f6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 07:05:18 +0200 Subject: [PATCH 054/114] FIX Language key --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f0d8df454cf..a86975b606f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1161,7 +1161,7 @@ else } // Morphy $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; From cededd97d28b2ab22d72a8ef2ae84512a8bb2e96 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 08:52:08 +0200 Subject: [PATCH 055/114] FIX Language key --- htdocs/adherents/card.php | 2 +- htdocs/adherents/type.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 373e8b953f6..c6ec8569a09 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1181,7 +1181,7 @@ else } // Morphy $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 19790159c22..4251ba45ab9 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -342,7 +342,7 @@ if ($action == 'create') // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; @@ -775,7 +775,7 @@ if ($rowid > 0) // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; From 858e8a826f3a0a8ddab94061ffa574b029233148 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 26 Jul 2019 14:42:59 +0200 Subject: [PATCH 056/114] FIX: use rounding to compare the amounts --- ...e_20_modWorkflow_WorkflowManager.class.php | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index e478e265652..5c13e372640 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -105,8 +105,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['propal'] as $element) { $ret=$element->classifyBilled($user); @@ -134,7 +134,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -157,8 +157,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['propal'] as $element) { $ret=$element->classifyBilled($user); @@ -186,8 +186,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['order_supplier'] as $element) { $ret=$element->classifyBilled($user); @@ -209,8 +209,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['supplier_proposal'] as $element) { $ret=$element->classifyBilled($user); @@ -237,7 +237,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog( "Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht) ); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -310,4 +310,26 @@ class InterfaceWorkflowManager extends DolibarrTriggers return 0; } + /** + * @param Object $conf Dolibarr settings object + * @param float $totalonlinkedelements Sum of total amounts (excl VAT) of + * invoices linked to $object + * @param float $object_total_ht The total amount (excl VAT) of the object + * (an order, a proposal, a bill, etc.) + * @return bool True if the amounts are equal (arithmetic errors within tolerance margin) + * True if the module is configured to skip the amount equality check + * False otherwise. + */ + private function shouldClassify($conf, $totalonlinkedelements, $object_total_ht) + { + // if the configuration allows unmatching amounts, allow classification anyway + if (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) { + return true; + } + // if the rounded amount difference is zero, allow classification, else deny + return 0 == round( + $totalonlinkedelements - $object_total_ht, + $conf->global->MAIN_MAX_DECIMALS_UNIT + ); + } } From 56f124844c353306307728f17eb3ba211a8710b9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 10:04:28 +0200 Subject: [PATCH 057/114] Test in progress --- .../class/accountancyexport.class.php | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1b477a57ae9..904388db64d 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -938,20 +938,14 @@ class AccountancyExport $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); - if ($line->doc_type == 'supplier_invoice') { - $type_enregistrement = 'F'; - } elseif ($line->doc_type == 'customer_invoice') { - $type_enregistrement = 'C'; - } else { - $type_enregistrement = 'E'; - } + $type_enregistrement = 'E'; // For write movement print $type_enregistrement . $separator; - print $line->code_journal . $separator; + print substr($line->code_journal, 0, 2) . $separator; print $line->id . $separator; print $line->piece_num . $separator; print $date_document . $separator; print $line->label_operation . $separator; - print $separator; + print $line->date_lim_reglement . $separator; if ($line->doc_type == 'supplier_invoice') { if ($line->montant < 0) { @@ -969,9 +963,18 @@ class AccountancyExport $nature_piece = ''; } print $nature_piece . $separator; + if (! empty($line->subledger_account)) { - print $line->numero_compte . $separator; + if ($line->doc_type == 'supplier_invoice') { + $racine_subledger_account = '40'; + } elseif ($line->doc_type == 'customer_invoice') { + $racine_subledger_account = '41'; + } else { + $nature_piece = ''; + } + print $racine_subledger_account . $separator; } + print price(abs($line->montant)) . $separator; print $line->sens . $separator; print length_accountg($line->numero_compte) . $separator; @@ -984,11 +987,11 @@ class AccountancyExport } if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) { - print 'F' . $separator; + print 'F'; } elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) { - print 'C' . $separator; + print 'C'; } else { - print $separator; + print ''; } print $end_line; } From a5e3adc6f1453a3719fa0aeda7a8e01fe2ffb5cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 10:51:17 +0200 Subject: [PATCH 058/114] Fix travis --- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/expedition/class/expedition.class.php | 4 ++-- htdocs/expensereport/class/expensereport.class.php | 4 ++-- htdocs/fichinter/class/fichinter.class.php | 4 ++-- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- htdocs/livraison/class/livraison.class.php | 4 ++-- htdocs/reception/class/reception.class.php | 4 ++-- htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index dd861d5dc47..40b4e89dfc5 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -584,8 +584,8 @@ class BOM extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'bom/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5de2c9b23f5..d957235d967 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1809,8 +1809,8 @@ class Propal extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'propale/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'propale/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'propale/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'propale/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d0e0addbc94..15156688603 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -425,8 +425,8 @@ class Commande extends CommonOrder if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'commande/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'commande/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2a9a4f5686d..216282d369e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2419,8 +2419,8 @@ class Facture extends CommonInvoice if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'facture/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'facture/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0b08d3723da..bfc18faf123 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -487,8 +487,8 @@ class Contrat extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'contract/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'contract/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 37f191a0ab0..3205a245285 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -814,8 +814,8 @@ class Expedition extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/sending/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'expedition/sending/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 2d9795e6f59..63b0b798a29 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1152,8 +1152,8 @@ class ExpenseReport extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expensereport/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'expensereport/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expensereport/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index ce066fc8c11..c987e6ffc58 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -577,8 +577,8 @@ class Fichinter extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'ficheinter/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'ficheinter/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b32e90c311d..c85bfaaf2d3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -552,8 +552,8 @@ class CommandeFournisseur extends CommonOrder if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/commande/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'fournisseur/commande/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/commande/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b13925bf29d..31780d33ed5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1420,8 +1420,8 @@ class FactureFournisseur extends CommonInvoice if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index f24a2aee713..88cf4e1355a 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -442,8 +442,8 @@ class Livraison extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/receipt/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'expedition/receipt/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/receipt/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expedition/receipt/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 84f95e40b9a..e89eb2c595b 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -644,8 +644,8 @@ class Reception extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'reception/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'reception/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'reception/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 786485ad6dd..cb4f774a951 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1485,8 +1485,8 @@ class SupplierProposal extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->newref."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'supplier_proposal/".$this->newref."'"; - $sql.= " WHERE filename LIKE '".$this->ref."%' AND filepath = 'supplier_proposal/".$this->ref."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'supplier_proposal/".$this->db->escape($this->newref)."'"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'supplier_proposal/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } From f82571120675a2b22606d13f9f0077e1fbb506dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 11:01:29 +0200 Subject: [PATCH 059/114] Code comment --- htdocs/core/modules/societe/modules_societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index d185b4cfcf7..4a873847d8a 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -393,7 +393,7 @@ abstract class ModeleAccountancyCode * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int <0 if KO, >0 if OK - * @deprecated Use the new function generateDocument of Facture class + * @deprecated Use the new function generateDocument of Objects class * @see Societe::generateDocument() */ function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) From 7931f0b422b6f193606079a6c3368d33ee18e916 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 11:06:39 +0200 Subject: [PATCH 060/114] Fix sql error --- htdocs/bom/class/bom.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/livraison/class/livraison.class.php | 2 +- htdocs/reception/class/reception.class.php | 2 +- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 40b4e89dfc5..7ad86b59ae8 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -585,7 +585,7 @@ class BOM extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d957235d967..a9746ca6f65 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1810,7 +1810,7 @@ class Propal extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'propale/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'propale/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'propale/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 15156688603..434d43e8ffa 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -426,7 +426,7 @@ class Commande extends CommonOrder { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'commande/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 216282d369e..a8b75341ed3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2420,7 +2420,7 @@ class Facture extends CommonInvoice { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'facture/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index bfc18faf123..147d31311d3 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -488,7 +488,7 @@ class Contrat extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'contract/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3205a245285..7fc4def441b 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -815,7 +815,7 @@ class Expedition extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/sending/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/sending/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 63b0b798a29..1160a6dcb94 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1153,7 +1153,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expensereport/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index c987e6ffc58..4ce2aa954b2 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -578,7 +578,7 @@ class Fichinter extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c85bfaaf2d3..d15545e4cda 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -553,7 +553,7 @@ class CommandeFournisseur extends CommonOrder { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/commande/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 31780d33ed5..9fe2f9bf6ed 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1421,7 +1421,7 @@ class FactureFournisseur extends CommonInvoice { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 88cf4e1355a..a8eee72df33 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -443,7 +443,7 @@ class Livraison extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'expedition/receipt/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'expedition/receipt/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expedition/receipt/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index e89eb2c595b..3e2776675a1 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -645,7 +645,7 @@ class Reception extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'reception/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'reception/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index cb4f774a951..481d80cab57 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1486,7 +1486,7 @@ class SupplierProposal extends CommonObject { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'supplier_proposal/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this-ref)."%' AND filepath = 'supplier_proposal/".$this->db->escape($this-ref)."' and entity = ".$conf->entity; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'supplier_proposal/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (! $resql) { $error++; $this->error = $this->db->lasterror(); } From 87fc3c39689a35b872902e32aaba66850a81c663 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Mon, 29 Jul 2019 13:54:48 +0200 Subject: [PATCH 061/114] FIX: expedition card: infinite loop for printObjectLine hook if return > 0 --- htdocs/expedition/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ae9ef67f755..326d378a199 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1586,9 +1586,9 @@ if ($action == 'create') print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); print ''; } - - $indiceAsked++; } + + $indiceAsked++; } print "
'; - print $langs->trans('RetainedWarrantyDateLimit'); + // Retained warranty payment term + print '
'; + print ''; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer){ - print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer){ + print ''; } print '
'; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id . '">' . img_edit($langs->trans('setretainedwarrantyDateLimit'), 1) . 'id . '">' . img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1) . '
'; @@ -3983,21 +4062,66 @@ else if ($id > 0 || ! empty($ref)) $defaultDate = $object->date; } - if ($action == 'editretainedwarrantydatelimit') + if ($action == 'editretainedwarrantypaymentterms') { //date('Y-m-d',$object->date_lim_reglement) print ''; - print ''; + print ''; print ''; - print ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement'); print ''; print ''; } else { - print dol_print_date($defaultDate); + print $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->retained_warranty_fk_cond_reglement, 'none'); + if(!$displayWarranty){ + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); + } } print '
'; + print ''; + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer){ + print ''; + } + + print '
'; + print $langs->trans('RetainedWarrantyDateLimit'); + print 'id . '">' . img_edit($langs->trans('setretainedwarrantyDateLimit'), 1) . '
'; + print '
'; + $defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement); + if($object->date > $defaultDate){ + $defaultDate = $object->date; + } + + if ($action == 'editretainedwarrantydatelimit') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } + else + { + print dol_print_date($object->retained_warranty_date_limit, 'day'); + } + print '
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement)) . ' :' . price($billedWithRetainedWarranty) . ' 
' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')) . ' :' . price($billedWithRetainedWarranty) . ' 
'; print $langs->trans("RetainedWarranty") . ' ('.$object->retained_warranty.'%)'; - print !empty($object->retained_warranty_date_limit)?' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit)):''; + print !empty($object->retained_warranty_date_limit)?' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):''; print ' :' . price($retainedWarranty) . ' 
' . $langs->trans('PaymentConditionsShortRetainedWarranty') . ''; $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement'); + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); print '
'.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - //print ''; + //print ''; print ''; + print ''; + print ''; + print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -264,11 +285,19 @@ if ($result) print '
'; + print $obj->user_agent; + print ''; + print $obj->prefix_session; + print ''; $htmltext=''.$langs->trans("UserAgent").': '.($obj->user_agent?$obj->user_agent:$langs->trans("Unknown")); + $htmltext.='
'.$langs->trans("PrefixSession").': '.($obj->prefix_session?$obj->prefix_session:$langs->trans("Unknown")); print $form->textwithpicto('', $htmltext); print '
'.$langs->trans("Nature").''; print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy",'alpha'):$object->morphy)); print "
'.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy)); print "
'.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print "
'.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print "
"; From 96380f01c6170a853602eb7f6ffab777d788073e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 15:41:53 +0200 Subject: [PATCH 062/114] Test in progress --- .../class/accountancyexport.class.php | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 904388db64d..10ebabc4f8a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -938,15 +938,22 @@ class AccountancyExport $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + // TYPE $type_enregistrement = 'E'; // For write movement print $type_enregistrement . $separator; + // JNAL print substr($line->code_journal, 0, 2) . $separator; + // NECR print $line->id . $separator; + // NPIE print $line->piece_num . $separator; + // DATP print $date_document . $separator; + // LIBE print $line->label_operation . $separator; + // DATH print $line->date_lim_reglement . $separator; - + // CNPI if ($line->doc_type == 'supplier_invoice') { if ($line->montant < 0) { $nature_piece = 'AF'; @@ -963,7 +970,8 @@ class AccountancyExport $nature_piece = ''; } print $nature_piece . $separator; - + // RACI + /* if (! empty($line->subledger_account)) { if ($line->doc_type == 'supplier_invoice') { $racine_subledger_account = '40'; @@ -973,19 +981,27 @@ class AccountancyExport $nature_piece = ''; } print $racine_subledger_account . $separator; + } else { + print $separator; } - + */ + // MONT print price(abs($line->montant)) . $separator; + // CODC print $line->sens . $separator; + // CPTG print length_accountg($line->numero_compte) . $separator; + // DATE print $date_creation . $separator; + // CLET print $line->lettering_code . $separator; + // DATL print $line->date_lettering . $separator; - + // CPTA if (! empty($line->subledger_account)) { print length_accounta($line->subledger_account) . $separator; } - + // CNAT if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) { print 'F'; } elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) { From 567c4bf97b402b850b0c6e2b8cf460df1c9fdf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Mon, 29 Jul 2019 18:17:48 +0200 Subject: [PATCH 063/114] FIX: resource tpls directories search resource tpls also in custom modules directories --- htdocs/resource/element_resource.php | 52 +++++++++++++++++++--------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 2e4085200a2..e2e0e0eb0ee 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2019 Josep Lluís Amador * * 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 @@ -474,29 +475,46 @@ else $linked_resources = $object->getElementResources($element, $element_id, $resource_obj); - - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) + // Output template part (modules that overwrite templates must declare this into descriptor) + $defaulttpldir='/core/tpl'; + $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); + + foreach($dirtpls as $module => $reldir) { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) + { + $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php'; + } + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } if ($mode != 'add' || $resource_obj != $resource_type) { - //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); - - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'))) + foreach($dirtpls as $module => $reldir) { - $res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; + if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) + { + $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php'; + } + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } } } From d2bc3ac1ef7f4cb97913e695e7f0ed33bcde2aa2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 29 Jul 2019 18:34:21 +0200 Subject: [PATCH 064/114] FIX stripe webhook ID constant set --- htdocs/stripe/admin/stripe.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 770678aae15..c2b2143f277 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -55,6 +55,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -64,6 +67,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); From 10344d9c34d9f9b9ac5864c5fed280cf799e887b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 02:24:04 +0200 Subject: [PATCH 065/114] Try to use the new scrutinizer engine --- .scrutinizer.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index b48aa158cce..85809bcc058 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,12 @@ # .scrutinizer.yml #build: # - php-scrutinizer-run +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run imports: - javascript From 5880d549fbe430580b32ab3bc57e64b0c7c3baf0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 30 Jul 2019 11:55:46 +0200 Subject: [PATCH 066/114] Fix php error with const --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 61acf6e3a89..378d6087cc7 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ if ($action=="create" || $action=="start") } // Get the bank account dedicated to this point of sale module/terminal - $vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse; + $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here From 449ef9200752de8e3feea2eefd606de80c037ee0 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 30 Jul 2019 12:31:03 +0200 Subject: [PATCH 067/114] FIX: categories import: prevent mismatch between category type and object type --- .../modules/import/import_csv.modules.php | 21 ++++++++++++++----- .../modules/import/import_xlsx.modules.php | 21 ++++++++++++++----- htdocs/core/modules/modCategorie.class.php | 14 +++++++++---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index a6473eaeb8e..776d8dfa04f 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -493,15 +493,24 @@ class ImportCsv extends ModeleImports if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table" - if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg)) + if (preg_match('/^(.+)@([^:]+)(:.+)?$/',$objimport->array_import_regex[0][$val],$reg)) { $field=$reg[1]; $table=$reg[2]; + $filter=substr($reg[3], 1); + + $cachekey = $field.'@'.$table; + if(! empty($filter)) $cachekey.= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache + if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { $sql="SELECT ".$field." as aliasfield FROM ".$table; + if(! empty($filter)) + { + $sql.= ' WHERE ' . $filter; + } + $resql=$this->db->query($sql); if ($resql) { @@ -510,7 +519,7 @@ class ImportCsv extends ModeleImports while ($i < $num) { $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; + if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; $i++; } } @@ -521,9 +530,11 @@ class ImportCsv extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval,$this->cachefieldtable[$field.'@'.$table])) + if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval,$this->cachefieldtable[$cachekey])) { - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$table); + $tableforerror = $table; + if(! empty($filter)) $tableforerror.= ':'.$filter; + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$tableforerror); $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 7f222f523ca..d58fd16cf2f 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -519,15 +519,24 @@ class ImportXlsx extends ModeleImports if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table" - if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg)) + if (preg_match('/^(.+)@([^:]+)(:.+)?$/',$objimport->array_import_regex[0][$val],$reg)) { $field=$reg[1]; $table=$reg[2]; + $filter=substr($reg[3], 1); + + $cachekey = $field.'@'.$table; + if(! empty($filter)) $cachekey.= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache + if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { $sql="SELECT ".$field." as aliasfield FROM ".$table; + if(! empty($filter)) + { + $sql.= ' WHERE ' . $filter; + } + $resql=$this->db->query($sql); if ($resql) { @@ -536,7 +545,7 @@ class ImportXlsx extends ModeleImports while ($i < $num) { $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; + if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; $i++; } } @@ -547,9 +556,11 @@ class ImportXlsx extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval,$this->cachefieldtable[$field.'@'.$table])) + if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval,$this->cachefieldtable[$cachekey])) { - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$table); + $tableforerror = $table; + if(! empty($filter)) $tableforerror.= ':'.$filter; + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn',$key,$newval,$field,$tableforerror); $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 50074779955..668b0ac9014 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -422,8 +422,8 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product'); - $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*" - ); + $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"); + $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0'); $this->import_convertvalue_array[$r]=array( 'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), @@ -441,7 +441,10 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' ); $this->import_convertvalue_array[$r]=array( @@ -460,7 +463,10 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0' ); $this->import_convertvalue_array[$r]=array( From 6aefa648e71a4f336c2f336be4c87f3bc0c92b71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 14:00:43 +0200 Subject: [PATCH 068/114] FIX CVE-2019-11199 --- htdocs/viewimage.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 073aaa9fb24..3db6e9fb803 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -170,7 +170,9 @@ if (GETPOST('type','alpha')) $type=GETPOST('type','alpha'); else $type=dol_mimetype($original_file); // Security: This wrapper is for images. We do not allow type/html -if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 1, 1, 1); +if (preg_match('/html/i', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 1, 1, 1); +// Security: This wrapper is for images. We do not allow files ending with .noexe +if (preg_match('/\.noexe$/i', $original_file)) accessforbidden('Error: Using the image wrapper to output a file ending with .noexe is not allowed.', 1, 1, 1); // Security: Delete string ../ into $original_file $original_file = str_replace("../","/", $original_file); From de293c4ef2ec2aa3a5c60eace86d448437facaf4 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Tue, 30 Jul 2019 14:09:03 +0200 Subject: [PATCH 069/114] FIX issue #9300: install error with PostgreSQL when using custom table prefix --- htdocs/install/step2.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 30b3ff7d64f..a53e5f07ee7 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -451,6 +451,11 @@ if ($action == "set") $buffer=trim($buffer); if ($buffer) { + // Replace the prefix in table names + if ($dolibarr_main_db_prefix != 'llx_') + { + $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer); + } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; $resql=$db->query($buffer,0,'dml'); From 703506c0e2674795fdf0dd2f9f78ee7f3c98b5b0 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 30 Jul 2019 14:11:21 +0200 Subject: [PATCH 070/114] FIX: import filter error --- htdocs/core/modules/import/import_csv.modules.php | 2 +- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 776d8dfa04f..e0ec89379af 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -497,7 +497,7 @@ class ImportCsv extends ModeleImports { $field=$reg[1]; $table=$reg[2]; - $filter=substr($reg[3], 1); + $filter=!empty($reg[3])?substr($reg[3], 1):''; $cachekey = $field.'@'.$table; if(! empty($filter)) $cachekey.= ':'.$filter; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index d58fd16cf2f..7d850ccfb8b 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -523,7 +523,7 @@ class ImportXlsx extends ModeleImports { $field=$reg[1]; $table=$reg[2]; - $filter=substr($reg[3], 1); + $filter=!empty($reg[3])?substr($reg[3], 1):''; $cachekey = $field.'@'.$table; if(! empty($filter)) $cachekey.= ':'.$filter; From db69a07bc448948cd9e2bcb12c1c8705a7e9c1bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 15:21:26 +0200 Subject: [PATCH 071/114] FIX Option THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION --- htdocs/societe/card.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 34784beefcb..3f7b97fee73 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -383,7 +383,7 @@ if (empty($reshook)) } else $object->canvas=$canvas; - if (GETPOST("private") == 1) // Ask to create a contact + if (GETPOST("private", 'int') == 1) // Ask to create a contact { $object->particulier = GETPOST("private"); @@ -1172,13 +1172,18 @@ else // If javascript on, we show option individual if ($conf->use_javascript_ajax) { - print '
'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'
'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; - print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'
'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'
'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; + print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'
'.$langs->trans("RUMWillBeGenerated").'
'.$langs->trans("DateRUM").''.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0,0,1, 'date_rum').'
'.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0, 0, 1, 'date_rum').'
'.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); From a871aa818b5d3e931bb2214ead646723735c771e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 18:15:04 +0200 Subject: [PATCH 074/114] FIX #11460 FIX #11492 FIX #11576 FIX #11590 --- htdocs/core/tpl/objectline_create.tpl.php | 50 ++++++++++++++++------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index bf46ecb9890..ebb9e8a41ac 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -255,6 +255,25 @@ if ($nolinesbefore) { { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } + + if (empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + { + ?> + + select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - ?> - - global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> + + '; echo ''; From e54c6fb5e2e1af537925b2d74457e6ee7caf12f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 19:30:56 +0200 Subject: [PATCH 075/114] FIX #11460 FIX #11492 FIX #11576 FIX #11590 --- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index ebb9e8a41ac..75c6f72e1df 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -256,7 +256,7 @@ if ($nolinesbefore) { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } - if (empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { ?> '; - } - } - } -} -else -{ - print '
'; - $langs->load("errors"); - print $langs->trans("ErrorModuleSetupNotComplete"); - print '
'; - $action=''; -} - - -print '
'; - -$head = array(); - -if ($action == 'editcontent') -{ - /* - * Editing global variables not related to a specific theme - */ - - $csscontent = @file_get_contents($filecss); - - $contentforedit = ''; - /*$contentforedit.=''."\n";*/ - $contentforedit .= $objectpage->content; - - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', 500, 'Full', '', true, true, true, ROWS_5, '90%'); - $doleditor->Create(0, '', false); -} print "
\n\n"; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a9746ca6f65..7a24fad83af 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3506,7 +3506,7 @@ class Propal extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal")); return ""; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6bb47f12a12..0fd061ac7ed 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2591,7 +2591,7 @@ if ($action == 'create' && $user->rights->commande->creer) } } else { $langs->load("errors"); - print ''; + print ''; } } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a8b75341ed3..13bc74bc6f1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3452,7 +3452,7 @@ class Facture extends CommonInvoice else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); return ""; } } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index d9a912ea50b..26e3f2792d6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -489,7 +489,7 @@ class RemiseCheque extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank")); return ""; } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index a3c79d23602..614782c519b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1141,7 +1141,7 @@ class Paiement extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); return ""; } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index d0c69fbe61b..ddbec62e413 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -78,7 +78,7 @@ if (empty($reshook)) // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $bprev = new BonPrelevement($db); $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); - + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate); if ($result < 0) { @@ -116,7 +116,7 @@ llxHeader('', $langs->trans("NewStandingOrder")); if (prelevement_check_config() < 0) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); } /*$h=0; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 4e2c4e2d3a5..1be716f8f61 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -58,7 +58,7 @@ llxHeader('', $langs->trans("CustomersStandingOrdersArea")); if (prelevement_check_config() < 0) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); } print load_fiche_titre($langs->trans("CustomersStandingOrdersArea")); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 147d31311d3..e81febde6df 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -245,7 +245,7 @@ class Contrat extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract")); return ""; } } diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 45ad69f6c64..b48fef9759a 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -701,7 +701,7 @@ class PaiementFourn extends Paiement else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Supplier")); return ""; } } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8e4d42559a8..4c8e761da9a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -90,7 +90,7 @@ ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field ErrorNumRefModel=A reference exists into database (%s) and is not compatible with this numbering rule. Remove record or renamed reference to activate this module. ErrorQtyTooLowForThisSupplier=Quantity too low for this vendor or no price defined on this product for this vendor ErrorOrdersNotCreatedQtyTooLow=Some orders haven't been created because of too-low quantities -ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Home - Setup - Modules to complete. +ErrorModuleSetupNotComplete=Setup of module %s looks to be uncomplete. Go on Home - Setup - Modules to complete. ErrorBadMask=Error on mask ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number ErrorBadMaskBadRazMonth=Error, bad reset value diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 1cf435379cd..a223f936638 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -90,7 +90,7 @@ ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis p ErrorNumRefModel=Une référence existe en base (%s) et est incompatible avec cette numérotation. Supprimez la ligne ou renommez la référence pour activer ce module. ErrorQtyTooLowForThisSupplier=Quantité insuffisante pour ce fournisseur ou aucun tarif défini sur ce produit pour ce fournisseur ErrorOrdersNotCreatedQtyTooLow=Certaines commandes n'ont pas été créées en raison de quantités trop faibles -ErrorModuleSetupNotComplete=La configuration des modules semble incomplète. Aller sur la page Accueil - Configuration - Modules pour corriger. +ErrorModuleSetupNotComplete=La configuration du module '%s' semble incomplète. Aller sur la page Accueil - Configuration - Modules pour corriger. ErrorBadMask=Erreur sur le masque ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 0a967cb10a7..a9e712c92db 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1928,7 +1928,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment // JS Code for Stripe if (empty($stripearrayofkeys['publishable_key'])) { - print info_admin($langs->trans("ErrorModuleSetupNotComplete", "stripe"), 0, 0, 'error'); + $langs->load("errors"); + print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); } else { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c9275293bb2..964812a05a3 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -224,21 +224,25 @@ $object = new Societe($db); * Actions */ -if ($action=="change") +if ($action=="change") // Change customer for TakePOS { $idcustomer = GETPOST('idcustomer', 'int'); $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant - $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS-".$place.")'"; + // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically + $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); - ?> - - + + load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("SupplierProposal")); return ""; } } diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index b952285747b..0a91e303a53 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -125,8 +125,8 @@ print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("CashDeskThirdPartyForSell").''; +print '
'.$langs->trans("CashDeskThirdPartyForSell").''; print $form->select_company($conf->global->{'CASHDESK_ID_THIRDPARTY'.$terminaltouse}, 'socid', '(s.client IN (1, 3) AND s.status = 1)', 1, 0, 0, array(), 0); print '
'.$langs->trans("CashDeskBankAccountForSell").''; + print ''; $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1); + if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse})) $atleastonefound++; print '
'.$langs->trans("CashDeskBankAccountForCheque").''; + print ''; $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1); + if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse})) $atleastonefound++; print '
'.$langs->trans("CashDeskBankAccountForCB").''; + print ''; $form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1); + if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) $atleastonefound++; print '
'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->libelle).''; + print ''; if (! empty($conf->global->$name)) $atleastonefound++; $cour=preg_match('/^LIQ.*/', $modep->code)?2:1; $form->select_comptes($conf->global->$name, $name, 0, "courant=".$cour, 1); @@ -162,7 +165,7 @@ if (! empty($conf->stock->enabled)) { print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; + print ''; if (empty($conf->productbatch->enabled)) { print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); } @@ -180,7 +183,7 @@ if (! empty($conf->stock->enabled)) print '
'.$langs->trans("CashDeskIdWareHouse").''; + print ''; if (! $disabled) { print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled); @@ -195,7 +198,7 @@ if (! empty($conf->stock->enabled)) print '
'; -if (empty($atleastonefound) && ! empty($conf->banque->enabled)) +if ($atleastonefound == 0 && ! empty($conf->banque->enabled)) { print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error'); } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 79c7eee3d56..e09c31664cd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -42,7 +42,7 @@ $langs->loadLangs(array("bills", "cashdesk")); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant /** * Abort invoice creationg with a given error message @@ -184,9 +184,21 @@ if (($action=="addline" || $action=="freezone") && $placeid == 0) $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; - $placeid = $invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; - $db->query($sql); + if ($invoice->socid <= 0) + { + $langs->load('errors'); + dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); + } + else + { + $placeid = $invoice->create($user); + if ($placeid < 0) + { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; + $db->query($sql); + } } if ($action == "addline") diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 702bb082714..dba42a105ae 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -352,7 +352,7 @@ function deleteline() { } function Customer() { - console.log("Open box to select the thirdparty"); + console.log("Open box to select the thirdparty place="+place); $.colorbox({href:"../societe/list.php?contextpage=poslist&nomassaction=1&place="+place, width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("Customer");?>"}); } @@ -619,7 +619,7 @@ $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; $sql.= " AND active = 1"; $sql.= " ORDER BY libelle"; -print $sql; + $resql = $db->query($sql); $paiementsModes = array(); if ($resql){ @@ -634,7 +634,8 @@ if ($resql){ } } if (empty($paiementsModes)) { - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + $langs->load('errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors'); } if (count($maincategories)==0) { setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 46e42c351c7..2ad328b5a88 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -120,7 +120,7 @@ if ($id > 0) if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete").''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).''; } else { @@ -161,7 +161,7 @@ if ($id > 0) if (empty($url)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete").''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).''; } else { From b8de18596a473bed196d3ce5ece0f4f60cadb139 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 12:40:51 +0200 Subject: [PATCH 088/114] FIX #11543 --- htdocs/ticket/class/api_tickets.class.php | 54 +++++++---------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 818514868c2..060ddc36ff3 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -218,17 +218,16 @@ class Tickets extends DolibarrApi * Get a list of tickets * * @param int $socid Filter list with thirdparty ID - * @param string $mode Use this param to filter list * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" * * @return array Array of ticket objects * */ - public function index($socid = 0, $mode = "", $sortfield = "s.rowid", $sortorder = "ASC", $limit = 0, $page = 0, $sqlfilters = '') + public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -243,51 +242,25 @@ class Tickets extends DolibarrApi $search_sale = DolibarrApiAccess::$user->id; } - $sql = "SELECT s.rowid"; + $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) } - $sql.= " FROM ".MAIN_DB_PREFIX."ticket as s"; + $sql.= " FROM ".MAIN_DB_PREFIX."ticket as t"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale } - $sql.= ' WHERE s.entity IN ('.getEntity('ticket', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql.= " AND s.fk_soc = sc.fk_soc"; + $sql.= " AND t.fk_soc = sc.fk_soc"; } if ($socid > 0) { - $sql.= " AND s.fk_soc = ".$socid; + $sql.= " AND t.fk_soc = ".$socid; } if ($search_sale > 0) { - $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - } - - // Example of use $mode - if ($mode == 'new') { - $sql.= " AND s.fk_statut IN (0)"; - } - if ($mode == 'read') { - $sql.= " AND s.fk_statut IN (1)"; - } - if ($mode == 'answered') { - $sql.= " AND s.fk_statut IN (3)"; - } - if ($mode == 'assign') { - $sql.= " AND s.fk_statut IN (4)"; - } - if ($mode == 'inprogress') { - $sql.= " AND s.fk_statut IN (5)"; - } - if ($mode == 'waiting') { - $sql.= " AND s.fk_statut IN (6)"; - } - if ($mode == 'closed') { - $sql.= " AND s.fk_statut IN (8)"; - } - if ($mode == 'deleted') { - $sql.= " AND s.fk_statut IN (9)"; + $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter @@ -344,7 +317,6 @@ class Tickets extends DolibarrApi * * @param array $request_data Request datas * @return int ID of ticket - * */ public function post($request_data = null) { @@ -364,9 +336,11 @@ class Tickets extends DolibarrApi if (empty($this->ticket->track_id)) { $this->ticket->track_id = generate_random_id(16); } - if (! $this->ticket->create(DolibarrApiAccess::$user)) { - throw new RestException(500); + + if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); } + return $this->ticket->id; } @@ -561,8 +535,12 @@ class Tickets extends DolibarrApi "lastname", "firstname", "civility_id", + "canvas", "cache_msgs_ticket", "cache_logs_ticket", + "cache_types_tickets", + "cache_category_tickets", + "regeximgext", "statuts_short", "statuts" ); From 8f2e781df6f67ba53e9b868a6f3350acd8a9eddf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 12:42:12 +0200 Subject: [PATCH 089/114] FIX #11537 --- htdocs/admin/clicktodial.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 7f4a167edd9..99c6cea7b39 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -37,12 +37,12 @@ $action = GETPOST('action', 'aZ09'); /* * Actions */ - + if ($action == 'setvalue' && $user->admin) { - $result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); - + $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + if ($result1 >= 0 && $result2 >= 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); From ac715b5147e0d263a65297060fd2758298f5bfd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 12:53:17 +0200 Subject: [PATCH 090/114] Upgrade Stripe lib to 6.41 to support SetupIntent --- COPYRIGHT | 2 +- htdocs/includes/stripe/CHANGELOG.md | 40 +++++++++ htdocs/includes/stripe/README.md | 19 +++- htdocs/includes/stripe/VERSION | 2 +- htdocs/includes/stripe/init.php | 3 + htdocs/includes/stripe/lib/Account.php | 44 +++++----- .../stripe/lib/BalanceTransaction.php | 37 ++++++-- htdocs/includes/stripe/lib/BankAccount.php | 10 +++ htdocs/includes/stripe/lib/Charge.php | 5 ++ .../includes/stripe/lib/Checkout/Session.php | 10 +++ htdocs/includes/stripe/lib/CreditNote.php | 1 + htdocs/includes/stripe/lib/Customer.php | 55 +++++++++++- .../stripe/lib/CustomerBalanceTransaction.php | 88 +++++++++++++++++++ htdocs/includes/stripe/lib/Invoice.php | 38 +++++--- .../stripe/lib/Issuing/Transaction.php | 2 + htdocs/includes/stripe/lib/Order.php | 2 +- htdocs/includes/stripe/lib/PaymentIntent.php | 13 +++ htdocs/includes/stripe/lib/Person.php | 2 +- .../stripe/lib/Radar/EarlyFraudWarning.php | 36 ++++++++ htdocs/includes/stripe/lib/SetupIntent.php | 75 ++++++++++++++++ htdocs/includes/stripe/lib/Source.php | 1 + htdocs/includes/stripe/lib/Stripe.php | 4 +- htdocs/includes/stripe/lib/Subscription.php | 2 + htdocs/includes/stripe/lib/TaxId.php | 5 +- htdocs/includes/stripe/lib/Util/Util.php | 3 + htdocs/includes/stripe/lib/Webhook.php | 4 +- .../includes/stripe/lib/WebhookSignature.php | 2 +- 27 files changed, 449 insertions(+), 56 deletions(-) create mode 100644 htdocs/includes/stripe/lib/CustomerBalanceTransaction.php create mode 100644 htdocs/includes/stripe/lib/Radar/EarlyFraudWarning.php create mode 100644 htdocs/includes/stripe/lib/SetupIntent.php diff --git a/COPYRIGHT b/COPYRIGHT index ea0c6453486..f58095e1558 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -32,7 +32,7 @@ PSR/simple-cache ? Library for cache (used by PHPSp Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Sabre 3.2.2 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP -Stripe 6.35 MIT licence Yes Library for Stripe module +Stripe 6.41 MIT licence Yes Library for Stripe module TCPDF 6.2.25 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement diff --git a/htdocs/includes/stripe/CHANGELOG.md b/htdocs/includes/stripe/CHANGELOG.md index 26b449ff039..bed9cff5722 100644 --- a/htdocs/includes/stripe/CHANGELOG.md +++ b/htdocs/includes/stripe/CHANGELOG.md @@ -1,5 +1,45 @@ # Changelog +## 6.41.0 - 2019-07-31 +* [#683](https://github.com/stripe/stripe-php/pull/683) Move the List Balance History API to `/v1/balance_transactions` + +## 6.40.0 - 2019-06-27 +* [#675](https://github.com/stripe/stripe-php/pull/675) Add support for `SetupIntent` resource and APIs + +## 6.39.2 - 2019-06-26 +* [#676](https://github.com/stripe/stripe-php/pull/676) Fix exception message in `CustomerBalanceTransaction::update()` + +## 6.39.1 - 2019-06-25 +* [#674](https://github.com/stripe/stripe-php/pull/674) Add new constants for `collection_method` on `Invoice` + +## 6.39.0 - 2019-06-24 +* [#673](https://github.com/stripe/stripe-php/pull/673) Enable request latency telemetry by default + +## 6.38.0 - 2019-06-17 +* [#649](https://github.com/stripe/stripe-php/pull/649) Add support for `CustomerBalanceTransaction` resource and APIs + +## 6.37.2 - 2019-06-17 +* [#671](https://github.com/stripe/stripe-php/pull/671) Add new PHPDoc +* [#672](https://github.com/stripe/stripe-php/pull/672) Add constants for `submit_type` on Checkout `Session` + +## 6.37.1 - 2019-06-14 +* [#670](https://github.com/stripe/stripe-php/pull/670) Add new PHPDoc + +## 6.37.0 - 2019-05-23 +* [#663](https://github.com/stripe/stripe-php/pull/663) Add support for `radar.early_fraud_warning` resource + +## 6.36.0 - 2019-05-22 +* [#661](https://github.com/stripe/stripe-php/pull/661) Add constants for new TaxId types +* [#662](https://github.com/stripe/stripe-php/pull/662) Add constants for BalanceTransaction types + +## 6.35.2 - 2019-05-20 +* [#655](https://github.com/stripe/stripe-php/pull/655) Add constants for payment intent statuses +* [#659](https://github.com/stripe/stripe-php/pull/659) Fix PHPDoc for various nested Account actions +* [#660](https://github.com/stripe/stripe-php/pull/660) Fix various PHPDoc + +## 6.35.1 - 2019-05-20 +* [#658](https://github.com/stripe/stripe-php/pull/658) Use absolute value when checking timestamp tolerance + ## 6.35.0 - 2019-05-14 * [#651](https://github.com/stripe/stripe-php/pull/651) Add support for the Capability resource and APIs diff --git a/htdocs/includes/stripe/README.md b/htdocs/includes/stripe/README.md index 8dca764d7d1..7d1b681c087 100644 --- a/htdocs/includes/stripe/README.md +++ b/htdocs/includes/stripe/README.md @@ -6,7 +6,11 @@ [![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php) [![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master) -You can sign up for a Stripe account at https://stripe.com. +The Stripe PHP library provides convenient access to the Stripe API from +applications written in the PHP language. It includes a pre-defined set of +classes for API resources that initialize themselves dynamically from API +responses which makes it compatible with a wide range of versions of the Stripe +API. ## Requirements @@ -56,7 +60,7 @@ echo $charge; ## Documentation -Please see https://stripe.com/docs/api for up-to-date documentation. +See the [PHP API docs](https://stripe.com/docs/api/php#intro). ## Legacy Version Support @@ -179,6 +183,17 @@ an intermittent network problem: [Idempotency keys][idempotency-keys] are added to requests to guarantee that retries are safe. +### Request latency telemetry + +By default, the library sends request latency telemetry to Stripe. These +numbers help Stripe improve the overall latency of its API for all users. + +You can disable this behavior if you prefer: + +```php +\Stripe\Stripe::setEnableTelemetry(false); +``` + ## Development Get [Composer][composer]. For example, on Mac OS: diff --git a/htdocs/includes/stripe/VERSION b/htdocs/includes/stripe/VERSION index b22907d080c..08c99ad1b68 100644 --- a/htdocs/includes/stripe/VERSION +++ b/htdocs/includes/stripe/VERSION @@ -1 +1 @@ -6.35.0 +6.41.0 diff --git a/htdocs/includes/stripe/init.php b/htdocs/includes/stripe/init.php index 2f6ccfbf67b..e893cfcda90 100644 --- a/htdocs/includes/stripe/init.php +++ b/htdocs/includes/stripe/init.php @@ -76,6 +76,7 @@ require(dirname(__FILE__) . '/lib/CountrySpec.php'); require(dirname(__FILE__) . '/lib/Coupon.php'); require(dirname(__FILE__) . '/lib/CreditNote.php'); require(dirname(__FILE__) . '/lib/Customer.php'); +require(dirname(__FILE__) . '/lib/CustomerBalanceTransaction.php'); require(dirname(__FILE__) . '/lib/Discount.php'); require(dirname(__FILE__) . '/lib/Dispute.php'); require(dirname(__FILE__) . '/lib/EphemeralKey.php'); @@ -104,6 +105,7 @@ require(dirname(__FILE__) . '/lib/Payout.php'); require(dirname(__FILE__) . '/lib/Person.php'); require(dirname(__FILE__) . '/lib/Plan.php'); require(dirname(__FILE__) . '/lib/Product.php'); +require(dirname(__FILE__) . '/lib/Radar/EarlyFraudWarning.php'); require(dirname(__FILE__) . '/lib/Radar/ValueList.php'); require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php'); require(dirname(__FILE__) . '/lib/Recipient.php'); @@ -112,6 +114,7 @@ require(dirname(__FILE__) . '/lib/Refund.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportType.php'); require(dirname(__FILE__) . '/lib/Review.php'); +require(dirname(__FILE__) . '/lib/SetupIntent.php'); require(dirname(__FILE__) . '/lib/SKU.php'); require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php'); require(dirname(__FILE__) . '/lib/Source.php'); diff --git a/htdocs/includes/stripe/lib/Account.php b/htdocs/includes/stripe/lib/Account.php index 0e84951dcd0..1adc6b79d53 100644 --- a/htdocs/includes/stripe/lib/Account.php +++ b/htdocs/includes/stripe/lib/Account.php @@ -152,8 +152,8 @@ class Account extends ApiResource /** - * @param string|null $id The ID of the account to which the capability belongs. - * @param string|null $capabilityId The ID of the capability to retrieve. + * @param string $id The ID of the account to which the capability belongs. + * @param string $capabilityId The ID of the capability to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -165,8 +165,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the capability belongs. - * @param string|null $capabilityId The ID of the capability to update. + * @param string $id The ID of the account to which the capability belongs. + * @param string $capabilityId The ID of the capability to update. * @param array|null $params * @param array|string|null $opts * @@ -178,7 +178,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the capabilities. + * @param string $id The ID of the account on which to retrieve the capabilities. * @param array|null $params * @param array|string|null $opts * @@ -190,7 +190,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the external account. + * @param string $id The ID of the account on which to create the external account. * @param array|null $params * @param array|string|null $opts * @@ -202,8 +202,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to retrieve. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -215,8 +215,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to update. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to update. * @param array|null $params * @param array|string|null $opts * @@ -228,8 +228,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to delete. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to delete. * @param array|null $params * @param array|string|null $opts * @@ -241,7 +241,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the external accounts. + * @param string $id The ID of the account on which to retrieve the external accounts. * @param array|null $params * @param array|string|null $opts * @@ -253,7 +253,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the login link. + * @param string $id The ID of the account on which to create the login link. * @param array|null $params * @param array|string|null $opts * @@ -280,7 +280,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the person. + * @param string $id The ID of the account on which to create the person. * @param array|null $params * @param array|string|null $opts * @@ -292,8 +292,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to retrieve. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -305,8 +305,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to update. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to update. * @param array|null $params * @param array|string|null $opts * @@ -318,8 +318,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to delete. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to delete. * @param array|null $params * @param array|string|null $opts * @@ -331,7 +331,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the persons. + * @param string $id The ID of the account on which to retrieve the persons. * @param array|null $params * @param array|string|null $opts * diff --git a/htdocs/includes/stripe/lib/BalanceTransaction.php b/htdocs/includes/stripe/lib/BalanceTransaction.php index cd9b79ae675..403c4aa173e 100644 --- a/htdocs/includes/stripe/lib/BalanceTransaction.php +++ b/htdocs/includes/stripe/lib/BalanceTransaction.php @@ -31,11 +31,36 @@ class BalanceTransaction extends ApiResource use ApiOperations\Retrieve; /** - * @return string The class URL for this resource. It needs to be special - * cased because it doesn't fit into the standard resource pattern. + * Possible string representations of the type of balance transaction. + * @link https://stripe.com/docs/api/balance/balance_transaction#balance_transaction_object-type */ - public static function classUrl() - { - return "/v1/balance/history"; - } + const TYPE_ADJUSTMENT = 'adjustment'; + const TYPE_ADVANCE = 'advance'; + const TYPE_ADVANCE_FUNDING = 'advance_funding'; + const TYPE_APPLICATION_FEE = 'application_fee'; + const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund'; + const TYPE_CHARGE = 'charge'; + const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer'; + const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold'; + const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release'; + const TYPE_ISSUING_TRANSACTION = 'issuing_transaction'; + const TYPE_PAYMENT = 'payment'; + const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund'; + const TYPE_PAYMENT_REFUND = 'payment_refund'; + const TYPE_PAYOUT = 'payout'; + const TYPE_PAYOUT_CANCEL = 'payout_cancel'; + const TYPE_PAYOUT_FAILURE = 'payout_failure'; + const TYPE_REFUND = 'refund'; + const TYPE_REFUND_FAILURE = 'refund_failure'; + const TYPE_RESERVE_TRANSACTION = 'reserve_transaction'; + const TYPE_RESERVED_FUNDS = 'reserved_funds'; + const TYPE_STRIPE_FEE = 'stripe_fee'; + const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee'; + const TYPE_TAX_FEE = 'tax_fee'; + const TYPE_TOPUP = 'topup'; + const TYPE_TOPUP_REVERSAL = 'topup_reversal'; + const TYPE_TRANSFER = 'transfer'; + const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; + const TYPE_TRANSFER_FAILURE = 'transfer_failure'; + const TYPE_TRANSFER_REFUND = 'transfer_refund'; } diff --git a/htdocs/includes/stripe/lib/BankAccount.php b/htdocs/includes/stripe/lib/BankAccount.php index 019a4d87cbd..3fdc9188c64 100644 --- a/htdocs/includes/stripe/lib/BankAccount.php +++ b/htdocs/includes/stripe/lib/BankAccount.php @@ -31,6 +31,16 @@ class BankAccount extends ApiResource use ApiOperations\Delete; use ApiOperations\Update; + /** + * Possible string representations of the bank verification status. + * @link https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status + */ + const STATUS_NEW = 'new'; + const STATUS_VALIDATED = 'validated'; + const STATUS_VERIFIED = 'verified'; + const STATUS_VERIFICATION_FAILED = 'verification_failed'; + const STATUS_ERRORED = 'errored'; + /** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. diff --git a/htdocs/includes/stripe/lib/Charge.php b/htdocs/includes/stripe/lib/Charge.php index 832a07c7c04..43274c5559c 100644 --- a/htdocs/includes/stripe/lib/Charge.php +++ b/htdocs/includes/stripe/lib/Charge.php @@ -11,7 +11,9 @@ namespace Stripe; * @property int $amount_refunded * @property string $application * @property string $application_fee + * @property int $application_fee_amount * @property string $balance_transaction + * @property mixed $billing_details * @property bool $captured * @property int $created * @property string $currency @@ -30,6 +32,8 @@ namespace Stripe; * @property mixed $outcome * @property bool $paid * @property string $payment_intent + * @property string $payment_method + * @property mixed $payment_method_details * @property string $receipt_email * @property string $receipt_number * @property string $receipt_url @@ -86,6 +90,7 @@ class Charge extends ApiResource const DECLINED_INVALID_PIN = 'invalid_pin'; const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available'; const DECLINED_LOST_CARD = 'lost_card'; + const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist'; const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available'; const DECLINED_NO_ACTION_TAKEN = 'no_action_taken'; const DECLINED_NOT_PERMITTED = 'not_permitted'; diff --git a/htdocs/includes/stripe/lib/Checkout/Session.php b/htdocs/includes/stripe/lib/Checkout/Session.php index 968d58cf632..33fc6a08ab2 100644 --- a/htdocs/includes/stripe/lib/Checkout/Session.php +++ b/htdocs/includes/stripe/lib/Checkout/Session.php @@ -15,6 +15,7 @@ namespace Stripe\Checkout; * @property bool $livemode * @property string $payment_intent * @property string[] $payment_method_types + * @property string $submit_type * @property string $subscription * @property string $success_url * @@ -27,4 +28,13 @@ class Session extends \Stripe\ApiResource use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\Retrieve; + + /** + * Possible string representations of submit type. + * @link https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type + */ + const SUBMIT_TYPE_AUTO = 'auto'; + const SUBMIT_TYPE_BOOK = 'book'; + const SUBMIT_TYPE_DONATE = 'donate'; + const SUBMIT_TYPE_PAY = 'pay'; } diff --git a/htdocs/includes/stripe/lib/CreditNote.php b/htdocs/includes/stripe/lib/CreditNote.php index 169ed0815c3..66351ffb828 100644 --- a/htdocs/includes/stripe/lib/CreditNote.php +++ b/htdocs/includes/stripe/lib/CreditNote.php @@ -8,6 +8,7 @@ namespace Stripe; * @property string $id * @property string $object * @property int $amount + * @property string $customer_balance_transaction * @property int $created * @property string $currency * @property string $customer diff --git a/htdocs/includes/stripe/lib/Customer.php b/htdocs/includes/stripe/lib/Customer.php index 44f5e6e2f09..6e78f981ee4 100644 --- a/htdocs/includes/stripe/lib/Customer.php +++ b/htdocs/includes/stripe/lib/Customer.php @@ -7,8 +7,8 @@ namespace Stripe; * * @property string $id * @property string $object - * @property int $account_balance * @property mixed $address + * @property int $balance * @property string $created * @property string $currency * @property string $default_source @@ -26,6 +26,7 @@ namespace Stripe; * @property mixed $shipping * @property Collection $sources * @property Collection $subscriptions + * @property string $tax_exempt * @property Collection $tax_ids * * @package Stripe @@ -61,6 +62,7 @@ class Customer extends ApiResource return $savedNestedResources; } + const PATH_BALANCE_TRANSACTIONS = '/balance_transactions'; const PATH_SOURCES = '/sources'; const PATH_TAX_IDS = '/tax_ids'; @@ -264,4 +266,55 @@ class Customer extends ApiResource { return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts); } + + /** + * @param string|null $id The ID of the customer on which to create the balance transaction. + * @param array|null $params + * @param array|string|null $opts + * + * @return ApiResource + */ + public static function createBalanceTransaction($id, $params = null, $opts = null) + { + return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer to which the balance transaction belongs. + * @param string|null $balanceTransactionId The ID of the balance transaction to retrieve. + * @param array|null $params + * @param array|string|null $opts + * + * @return ApiResource + */ + public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null) + { + return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer on which to update the balance transaction. + * @param string|null $balanceTransactionId The ID of the balance transaction to update. + * @param array|null $params + * @param array|string|null $opts + * + * + * @return ApiResource + */ + public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null) + { + return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer on which to retrieve the customer balance transactions. + * @param array|null $params + * @param array|string|null $opts + * + * @return Collection The list of customer balance transactions. + */ + public static function allBalanceTransactions($id, $params = null, $opts = null) + { + return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts); + } } diff --git a/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php b/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php new file mode 100644 index 00000000000..06cafcd45c6 --- /dev/null +++ b/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php @@ -0,0 +1,88 @@ +instanceUrl() . '/cancel'; + list($response, $opts) = $this->_request('post', $url, $params, $options); + $this->refreshFrom($response, $opts); + return $this; + } + + /** + * @param array|null $params + * @param array|string|null $options + * + * @return SetupIntent The confirmed setup intent. + */ + public function confirm($params = null, $options = null) + { + $url = $this->instanceUrl() . '/confirm'; + list($response, $opts) = $this->_request('post', $url, $params, $options); + $this->refreshFrom($response, $opts); + return $this; + } +} diff --git a/htdocs/includes/stripe/lib/Source.php b/htdocs/includes/stripe/lib/Source.php index 31b7cf77bba..1e2c8c73565 100644 --- a/htdocs/includes/stripe/lib/Source.php +++ b/htdocs/includes/stripe/lib/Source.php @@ -18,6 +18,7 @@ namespace Stripe; * @property mixed $code_verification * @property int $created * @property string $currency + * @property string $customer * @property mixed $eps * @property string $flow * @property mixed $giropay diff --git a/htdocs/includes/stripe/lib/Stripe.php b/htdocs/includes/stripe/lib/Stripe.php index 027f22fd83c..2397ef9c418 100644 --- a/htdocs/includes/stripe/lib/Stripe.php +++ b/htdocs/includes/stripe/lib/Stripe.php @@ -47,7 +47,7 @@ class Stripe public static $maxNetworkRetries = 0; // @var boolean Whether client telemetry is enabled. Defaults to false. - public static $enableTelemetry = false; + public static $enableTelemetry = true; // @var float Maximum delay between retries, in seconds private static $maxNetworkRetryDelay = 2.0; @@ -55,7 +55,7 @@ class Stripe // @var float Initial delay between retries, in seconds private static $initialNetworkRetryDelay = 0.5; - const VERSION = '6.35.0'; + const VERSION = '6.41.0'; /** * @return string The API key used for requests. diff --git a/htdocs/includes/stripe/lib/Subscription.php b/htdocs/includes/stripe/lib/Subscription.php index 8b57d46b625..f5a46171d81 100644 --- a/htdocs/includes/stripe/lib/Subscription.php +++ b/htdocs/includes/stripe/lib/Subscription.php @@ -13,6 +13,7 @@ namespace Stripe; * @property mixed $billing_thresholds * @property bool $cancel_at_period_end * @property int $canceled_at + * @property string $collection_method * @property int $created * @property int $current_period_end * @property int $current_period_start @@ -31,6 +32,7 @@ namespace Stripe; * @property int $quantity * @property SubscriptionSchedule $schedule * @property int $start + * @property int $start_date * @property string $status * @property float $tax_percent * @property int $trial_end diff --git a/htdocs/includes/stripe/lib/TaxId.php b/htdocs/includes/stripe/lib/TaxId.php index 2993e2d1375..0f72a2ac95f 100644 --- a/htdocs/includes/stripe/lib/TaxId.php +++ b/htdocs/includes/stripe/lib/TaxId.php @@ -12,7 +12,6 @@ namespace Stripe; * @property string $country * @property int $created * @property string $customer - * @property bool $deleted * @property bool $livemode * @property string $type * @property string $value @@ -27,10 +26,12 @@ class TaxId extends ApiResource /** * Possible string representations of a tax id's type. - * @link https://stripe.com/docs/api/customers/tax_id_object#tax_id_object-type + * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type */ const TYPE_AU_ABN = 'au_abn'; const TYPE_EU_VAT = 'eu_vat'; + const TYPE_IN_GST = 'in_gst'; + const TYPE_NO_VAT = 'no_vat'; const TYPE_NZ_GST = 'nz_gst'; const TYPE_UNKNOWN = 'unknown'; diff --git a/htdocs/includes/stripe/lib/Util/Util.php b/htdocs/includes/stripe/lib/Util/Util.php index e21d45dac16..f9f15440023 100644 --- a/htdocs/includes/stripe/lib/Util/Util.php +++ b/htdocs/includes/stripe/lib/Util/Util.php @@ -88,6 +88,7 @@ abstract class Util \Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon', \Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote', \Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer', + \Stripe\CustomerBalanceTransaction::OBJECT_NAME => 'Stripe\\CustomerBalanceTransaction', \Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount', \Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute', \Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey', @@ -117,6 +118,7 @@ abstract class Util \Stripe\Person::OBJECT_NAME => 'Stripe\\Person', \Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan', \Stripe\Product::OBJECT_NAME => 'Stripe\\Product', + \Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => 'Stripe\\Radar\\EarlyFraudWarning', \Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList', \Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem', \Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient', @@ -125,6 +127,7 @@ abstract class Util \Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun', \Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType', \Stripe\Review::OBJECT_NAME => 'Stripe\\Review', + \Stripe\SetupIntent::OBJECT_NAME => 'Stripe\\SetupIntent', \Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU', \Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun', \Stripe\Source::OBJECT_NAME => 'Stripe\\Source', diff --git a/htdocs/includes/stripe/lib/Webhook.php b/htdocs/includes/stripe/lib/Webhook.php index e0ab3021a89..45c7dc0f30a 100644 --- a/htdocs/includes/stripe/lib/Webhook.php +++ b/htdocs/includes/stripe/lib/Webhook.php @@ -24,6 +24,8 @@ abstract class Webhook */ public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE) { + WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance); + $data = json_decode($payload, true); $jsonError = json_last_error(); if ($data === null && $jsonError !== JSON_ERROR_NONE) { @@ -33,8 +35,6 @@ abstract class Webhook } $event = Event::constructFrom($data); - WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance); - return $event; } } diff --git a/htdocs/includes/stripe/lib/WebhookSignature.php b/htdocs/includes/stripe/lib/WebhookSignature.php index 73e70dbd7de..9f8be8777b3 100644 --- a/htdocs/includes/stripe/lib/WebhookSignature.php +++ b/htdocs/includes/stripe/lib/WebhookSignature.php @@ -60,7 +60,7 @@ abstract class WebhookSignature } // Check if timestamp is within tolerance - if (($tolerance > 0) && ((time() - $timestamp) > $tolerance)) { + if (($tolerance > 0) && (abs(time() - $timestamp) > $tolerance)) { throw new Error\SignatureVerification( "Timestamp outside the tolerance zone", $header, From d495f7969faafe133545f15384ed6f15302ce1aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 13:11:20 +0200 Subject: [PATCH 091/114] FIX #11412 --- htdocs/ticket/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index f40d3afce33..2a4195cb07b 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -533,7 +533,9 @@ foreach($object->fields as $key => $val) } print '
'; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); - print Form::multiselectarray('search_fk_statut', $arrayofstatus, array_values($search[$key]), 0, 0, 'minwidth150', 1, 0, '', '', ''); + $selectedarray = null; + if ($search[$key]) $selectedarray = array_values($search[$key]); + print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); print ''; if ($action == 'editdate') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); @@ -464,7 +468,8 @@ if ($action == 'create') print ''; if ($action == 'editjournal') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); @@ -487,7 +492,8 @@ if ($action == 'create') print ''; if ($action == 'editdocref') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print ''; @@ -583,6 +589,8 @@ if ($action == 'create') print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print ''; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3169d3737d9..b3f5c3acfda 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -274,7 +274,6 @@ class AccountancyExport * Export format : CEGID * * @param array $objectLines data - * * @return void */ public function exportCegid($objectLines) @@ -300,7 +299,6 @@ class AccountancyExport * Export format : COGILOG * * @param array $objectLines data - * * @return void */ public function exportCogilog($objectLines) @@ -334,7 +332,6 @@ class AccountancyExport * Export format : COALA * * @param array $objectLines data - * * @return void */ public function exportCoala($objectLines) @@ -362,7 +359,6 @@ class AccountancyExport * Export format : BOB50 * * @param array $objectLines data - * * @return void */ public function exportBob50($objectLines) @@ -401,7 +397,6 @@ class AccountancyExport * Export format : CIEL * * @param array $TData data - * * @return void */ public function exportCiel(&$TData) @@ -442,7 +437,6 @@ class AccountancyExport * Export format : Quadratus * * @param array $TData data - * * @return void */ public function exportQuadratus(&$TData) @@ -526,7 +520,6 @@ class AccountancyExport * Export format : EBP * * @param array $objectLines data - * * @return void */ public function exportEbp($objectLines) @@ -563,7 +556,6 @@ class AccountancyExport * Export format : Agiris Isacompta * * @param array $objectLines data - * * @return void */ public function exportAgiris($objectLines) @@ -604,7 +596,6 @@ class AccountancyExport * Export format : OpenConcerto * * @param array $objectLines data - * * @return void */ public function exportOpenConcerto($objectLines) @@ -634,16 +625,17 @@ class AccountancyExport } /** - * Export format : Configurable + * Export format : Configurable CSV * * @param array $objectLines data - * * @return void */ public function exportConfigurable($objectLines) { global $conf; + $separator = $this->separator; + foreach ($objectLines as $line) { $tab = array(); // export configurable @@ -651,15 +643,14 @@ class AccountancyExport $tab[] = $line->piece_num; $tab[] = $date; $tab[] = $line->doc_ref; - $tab[] = $line->label_operation; + $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation; $tab[] = length_accountg($line->numero_compte); $tab[] = length_accounta($line->subledger_account); - $tab[] = price($line->debit); - $tab[] = price($line->credit); - $tab[] = price($line->montant); + $tab[] = price2num($line->debit); + $tab[] = price2num($line->credit); + $tab[] = price2num($line->montant); $tab[] = $line->code_journal; - $separator = $this->separator; print implode($separator, $tab) . $this->end_line; } } @@ -668,7 +659,6 @@ class AccountancyExport * Export format : FEC * * @param array $objectLines data - * * @return void */ public function exportFEC($objectLines) From a260e7391fb71c6f1396a97980dbbcf7d9e44512 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 14:22:45 +0200 Subject: [PATCH 093/114] FIX for #11232 --- htdocs/core/class/html.formmargin.class.php | 32 ++++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index f9b0a59280f..ea038fa8131 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -199,8 +199,6 @@ class FormMargin if (! $user->rights->margins->liretous) return; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - $marginInfo = $this->getMarginInfosArray($object, $force_price); if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better @@ -240,13 +238,13 @@ class FormMargin //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print '
'.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.price($marginInfo['pv_products']).''.price($marginInfo['pa_products']).''.price($marginInfo['margin_on_products']).''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').'
'.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.price($marginInfo['pv_services']).''.price($marginInfo['pa_services']).''.price($marginInfo['margin_on_services']).''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').'
'.$langs->trans('TotalMargin').''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.price($marginInfo['pv_total']).''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'
'; From 90ddc0a214ade20d36a7478f6634e27928444b2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 14:27:57 +0200 Subject: [PATCH 094/114] FIX #10930 --- htdocs/core/modules/project/doc/pdf_beluga.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index dfbe97c3fd5..8b6cd68f343 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -260,7 +260,7 @@ class pdf_beluga extends ModelePDFProjects complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); @@ -438,7 +438,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); } $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); if (is_array($elementarray) && count($elementarray) > 0) { From 2e3d700ef53fc307a80c7aaf1126bfb9fb11b401 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 31 Jul 2019 17:02:35 +0200 Subject: [PATCH 095/114] NEW export livre Charlemagne --- .../class/accountancyexport.class.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 10ebabc4f8a..6906d1d3b7a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -48,6 +48,7 @@ class AccountancyExport public static $EXPORT_TYPE_BOB50 = 35; public static $EXPORT_TYPE_CIEL = 40; public static $EXPORT_TYPE_SAGE50_SWISS = 45; + public static $EXPORT_TYPE_CHARLEMAGNE = 50; public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; @@ -108,6 +109,7 @@ class AccountancyExport self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), ); ksort($listofexporttypes, SORT_NUMERIC); @@ -202,6 +204,10 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), + self::$EXPORT_TYPE_CHARLEMAGNE => array( + 'label' => $langs->trans('Modelcsv_charlemagne'), + 'ACCOUNTING_EXPORT_FORMAT' => 'txt', + ), ), 'cr'=> array ( '1' => $langs->trans("Unix"), @@ -273,6 +279,9 @@ class AccountancyExport case self::$EXPORT_TYPE_FEC : $this->exportFEC($TData); break; + case self::$EXPORT_TYPE_CHARLEMAGNE : + $this->exportCharlemagne($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -1013,6 +1022,68 @@ class AccountancyExport } } + /** + * Export format : Charlemagne + * + * @param array $objectLines data + * + * @return void + */ + public function exportCharlemagne($objectLines) + { + global $langs; + $langs->load('compta'); + + $separator = "\t"; + $end_line = "\n"; + + /* + * Charlemagne export need header + */ + print $langs->transnoentitiesnoconv('Date') . $separator; + print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator; + print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator; + print $langs->transnoentitiesnoconv('Amount') . $separator; + print 'S' . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator; + print $end_line; + + foreach($objectLines as $line) { + + $date = dol_print_date($line->doc_date, '%Y%m%d'); + print $date . $separator; //Date + + print self::trunc($line->code_journal, 6) . $separator; //Journal code + + if(!empty($line->subledger_account)) $account = $line->subledger_account; + else $account = $line->numero_compte; + print self::trunc($account, 15) . $separator;//Account number + + print self::trunc($line->label_compte, 60) . $separator;//Account label + print self::trunc($line->doc_ref, 20) . $separator;//Piece + print self::trunc($line->label_operation, 60) . $separator;//Operation label + print price(abs($line->montant)) . $separator;//Amount + print $line->sens . $separator;//Direction + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $end_line; + + } + } + + /** * trunc * From eca1029cd8bfa4e070afc8a199de45661c1ddf03 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 1 Aug 2019 15:22:39 +0200 Subject: [PATCH 096/114] missing trans --- htdocs/langs/fr_FR/accountancy.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index de6f26337d7..8bbdfc93f42 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -295,6 +295,7 @@ Modelcsv_openconcerto=Export pour OpenConcerto (Test) Modelcsv_configurable=Export configurable Modelcsv_FEC=Export FEC Modelcsv_Sage50_Swiss=Export pour Sage 50 Suisse +Modelcsv_charlemagne=Export vers Charlemagne ChartofaccountsId=Id plan comptable ## Tools - Init accounting account on product / service From d6ae62478c8841fdfe58971494818b599f396d4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 15:42:44 +0200 Subject: [PATCH 097/114] FIX #10984 FIX reposition on "Build backup" button FIX Fatal error on dol_htmloutput_mesg with corrupted array --- htdocs/admin/tools/dolibarr_export.php | 11 ++++----- htdocs/admin/tools/export.php | 33 +++++++++++++------------- htdocs/core/js/lib_foot.js.php | 3 ++- htdocs/core/lib/functions.lib.php | 15 ++++++++---- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index e63aec50dca..c06314daa9a 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -446,8 +446,10 @@ print "\n";
-
" id="buttonGo" />
+
+ " id="buttonGo"> + +

'.$langs->trans("BackupResult").': '; print $_SESSION["commandbackupresult"]; @@ -598,9 +600,6 @@ print '
'; - - - admin) accessforbidden(); if ($file && ! $what) { //print DOL_URL_ROOT.'/dolibarr_export.php'; - header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod")))); + header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int')?'&page_y='.GETPOST('page_y', 'int'):'')); exit; } @@ -122,25 +122,15 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); - $ok=0; dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - foreach($arrayofallowedcommand as $allowedcommand) - { - $basenamecmddump=basename($cmddump); - if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command - { - $ok=1; - break; - } - } - if (! $ok) + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command { $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); } @@ -176,6 +166,18 @@ if ($what == 'postgresql') $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); + /* Not required, the command is output on screen but not ran for pgsql + if (! empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); + } + } */ + if (! $errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); @@ -193,7 +195,6 @@ if ($what == 'postgresql') } - if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); @@ -230,8 +231,8 @@ $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/ print '
'; */ -// Redirect t backup page -header("Location: dolibarr_export.php"); +// Redirect to backup page +header("Location: dolibarr_export.php".(GETPOST('page_y', 'int')?'?page_y='.GETPOST('page_y', 'int'):'')); $time_end = time(); diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 14c69259b98..79ad6d19115 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -148,6 +148,7 @@ print ' /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { var page_y = $(document).scrollTop(); + if (page_y > 0) { if (this.href) @@ -157,7 +158,7 @@ print ' } else { - console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y); + console.log("We click on tag with .reposition class but element is not an html tag, so we try to update input form field page_y with value "+page_y); jQuery("input[type=hidden][name=page_y]").val(page_y); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9aa6177adf4..20dd423dd4c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6554,10 +6554,17 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o $newmesgarray=array(); foreach($mesgarray as $val) { - $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); - $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); - $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); - $newmesgarray[]=$tmpmesgstring; + if (is_string($val)) + { + $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); + $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); + $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); + $newmesgarray[]=$tmpmesgstring; + } + else + { + dol_syslog("Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING); + } } $mesgarray=$newmesgarray; } From b066431e0e000008d63d2a9368a0487f84fa55a8 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Thu, 1 Aug 2019 15:46:34 +0200 Subject: [PATCH 098/114] Add phone format for Jamaica --- htdocs/core/lib/functions.lib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9aa6177adf4..8f92586f9c3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2447,6 +2447,13 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } } + elseif (strtoupper($countrycode) == "JM") + {//Jamaïque + if(dol_strlen($newphone) == 12) + {//ex: +1867_ABC_DEFG + $newphone = substr($newphone,0,5).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4); + } + } elseif (strtoupper($countrycode) == "MG") {//Madagascar if(dol_strlen($phone) == 13) From 18a56c7ef2e035991c6ea0aa287d2a5e51b5c34d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 1 Aug 2019 15:59:37 +0200 Subject: [PATCH 099/114] add some translation --- .../modules/fichinter/doc/pdf_soleil.modules.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index fa32d3df0d2..936eabeadda 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -136,12 +136,12 @@ class pdf_soleil extends ModelePDFFicheinter $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_logo = 1; // Display logo + $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 0; // Display payment mode + $this->option_condreg = 0; // Display payment terms + $this->option_codeproduitservice = 0; // Display product-service code + $this->option_multilang = 1; // Available in several languages $this->option_draft_watermark = 1; //Support add of a watermark on drafts // Get source company From 008a54ea19f9281a9ca037517e753627be164db9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:14:53 +0200 Subject: [PATCH 100/114] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8f92586f9c3..3b08b76a1e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2451,7 +2451,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli {//Jamaïque if(dol_strlen($newphone) == 12) {//ex: +1867_ABC_DEFG - $newphone = substr($newphone,0,5).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4); + $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); } } elseif (strtoupper($countrycode) == "MG") From 73715f00af69b236fa9f6be9b2635439541accce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:18:26 +0200 Subject: [PATCH 101/114] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e2a434c66ff..309948dff1c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4400,7 +4400,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ { if ($currency_code == 'auto') $currency_code=$conf->currency; - $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAN'); + $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD'); $listoflanguagesbefore=array('nl_NL'); if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) { From bf14b4b3d5cda59654e2ebac693bfaba119feda7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:20:18 +0200 Subject: [PATCH 102/114] Add Canada Dollar in currency that need symbol before --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 20dd423dd4c..e9f4301f8f2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4400,7 +4400,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ { if ($currency_code == 'auto') $currency_code=$conf->currency; - $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY'); + $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD'); $listoflanguagesbefore=array('nl_NL'); if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) { From 6693f9fbcab68129d60879c54816bedf3d23430c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:24:19 +0200 Subject: [PATCH 103/114] Fix phpcs --- htdocs/compta/sociales/list.php | 2 +- htdocs/install/step2.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index baa1f57a307..5f7f7d0fc0a 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -281,7 +281,7 @@ if ($resql) print '
'; if ($obj->periode) { - print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').''; + print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; } else { diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index b553166e8bc..172d2510287 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -453,7 +453,7 @@ if ($action == "set") // Replace the prefix in table names if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer); + $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix,$buffer); } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; From 5a719769bc3cca79dfb6d2b0320b09d626cc5e90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:29:18 +0200 Subject: [PATCH 104/114] Fix phpcs --- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- test/phpunit/HolidayTest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 10b2a5662f3..af9c0e2c412 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -622,7 +622,7 @@ class ImportXlsx extends ModeleImports if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." - if (preg_match('/^(.+)@([^:]+)(:.+)?$/',$objimport->array_import_regex[0][$val],$reg)) + if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { $field=$reg[1]; $table=$reg[2]; diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index 3e7ddfb7f0f..ce3312ba441 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -365,5 +365,4 @@ class HolidayTest extends PHPUnit\Framework\TestCase $localobjecta->updateBalance(); } - } From ace01f7442f28a6e3c5c4a07c88b5537ad068db8 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 1 Aug 2019 16:29:42 +0200 Subject: [PATCH 105/114] Fix wrong sql update version --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 6e38e8cff5b..61f4dc544ba 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -285,12 +285,6 @@ DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_acc --update llx_facture_fourn_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; --update llx_expensereport_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; - -ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; -ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; -ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit; - - ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); From 85dbec6ae7e6f957083f606215d00a68a0af6852 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 16:33:34 +0200 Subject: [PATCH 106/114] Move sql in correct migration file --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index b5795a75639..bd556d089cd 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -44,6 +44,11 @@ create table llx_entrepot_extrafields ALTER TABLE llx_entrepot_extrafields ADD INDEX idx_entrepot_extrafields (fk_object); +ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit; + + ALTER TABLE llx_c_shipment_mode ADD COLUMN entity integer DEFAULT 1 NOT NULL; ALTER TABLE llx_c_shipment_mode DROP INDEX uk_c_shipment_mode; From 808d6ba389f4ca0d2beda5bb7a78b44c7780d919 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2019 18:30:39 +0200 Subject: [PATCH 107/114] Fix phpcs --- htdocs/install/step2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 172d2510287..cf235762b86 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -453,7 +453,7 @@ if ($action == "set") // Replace the prefix in table names if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix,$buffer); + $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; From c01ac05aecabdbef49031116106bf853253bc4dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 12:04:06 +0200 Subject: [PATCH 108/114] FIX Content of email for subscription --- htdocs/adherents/class/subscription.class.php | 22 +++++----- htdocs/adherents/subscription/card.php | 33 +++++++-------- ...terface_50_modAgenda_ActionsAuto.class.php | 40 +++++++++++++------ 3 files changed, 55 insertions(+), 40 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 71660c0cd8c..571879788ee 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -53,21 +53,21 @@ class Subscription extends CommonObject * @var integer */ public $datec; - + /** * Date modification record (tms) * * @var integer */ public $datem; - + /** * Subscription start date (date subscription) * * @var integer */ public $dateh; - + /** * Subscription end date * @@ -128,10 +128,11 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == null) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + + if ($this->fk_type == null) { // If type not defined, we use the type of member $type=$member->typeid; } else { $type=$this->fk_type; @@ -151,11 +152,13 @@ class Subscription extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->fk_type = $type; } if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers @@ -257,7 +260,8 @@ class Subscription extends CommonObject $result=$member->update_end_date($user); if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index a8478f35e88..e44995b263f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2019 Laurent Destailleur * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -205,18 +205,18 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print $form->showrefnav($object, 'rowid', $linkback, 1); print '
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Type").''; print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); print'
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("DateSubscription").''; print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); @@ -309,6 +309,12 @@ if ($rowid && $action != 'edit') print ''; + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; + // Type print ''; print ''; @@ -322,17 +328,6 @@ if ($rowid && $action != 'edit') } print ''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; - - // Date record - /*print ''; - print ''; - print '';*/ - // Date subscription print ''; print ''; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bdd07c4e38d..07499ac8893 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -649,12 +649,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc; @@ -664,12 +672,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc; From dc79f8d26b6f3bbd618c914ffa6b7129d9767845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 16:52:36 +0200 Subject: [PATCH 109/114] Code comment --- htdocs/core/ajax/extraparams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 7ef25e62b8b..e039529eef7 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -17,7 +17,7 @@ /** * \file /htdocs/core/ajax/extraparams.php - * \brief File to return Ajax response on set extra parameters of elements + * \brief File to make Ajax action on setting extra parameters of elements */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal From 89a5a8188fd5df83f1a55e095b4d241e79017393 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 17:12:03 +0200 Subject: [PATCH 110/114] Fix A file for a hidden feature provides a service without security checks. --- htdocs/core/ajax/objectonoff.php | 26 ++++++++++++++++++++++++-- htdocs/core/ajax/security.php | 2 +- htdocs/core/lib/ajax.lib.php | 5 +++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 6b06cccd50c..987a59ec3fb 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -15,8 +15,9 @@ */ /** - * \file htdocs/core/ajax/productonoff.php - * \brief File to set tosell and tobuy for product + * \file htdocs/core/ajax/objectonoff.php + * \brief File to set status for an object + * This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal @@ -36,6 +37,13 @@ $field=GETPOST('field', 'alpha'); $element=GETPOST('element', 'alpha'); $object = new GenericObject($db); + +// Security check +if (! empty($user->societe_id)) + $socid = $user->societe_id; + + + /* * View */ @@ -44,6 +52,20 @@ top_httphead(); print ''."\n"; +if ($element == 'societe' && in_array($field, array('status'))) +{ + $result = restrictedArea($user, 'societe', $id); +} +elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) +{ + $result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); +} +else +{ + accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1); + exit; +} + // Registering new values if (($action == 'set') && ! empty($id)) $object->setValueFrom($field, $value, $element, $id); diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 9e7dea2ef95..faaddd31b23 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -17,7 +17,7 @@ /** * \file htdocs/core/ajax/security.php - * \brief This ajax component is used to generated has keys for security purposes + * \brief This ajax component is used to generated hash keys for security purposes * like key to use into URL to protect them. */ diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index a96e63a4f43..43f4723d695 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -538,11 +538,12 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof } /** - * On/off button for object + * On/off button to change status of an object + * This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php * * @param Object $object Object to set * @param string $code Name of constant : status or status_buy for product by example - * @param string $field Name of database field : tosell or tobuy for product by example + * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example * @param string $text_on Text if on * @param string $text_off Text if off * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) From b9ee95314ad89591be18b3aeff1615170615e2b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 17:12:59 +0200 Subject: [PATCH 111/114] SEC restrictedArea protects also the 'update' action --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 051f3a5392a..2ee5a45c010 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -279,7 +279,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f // Check write permission from module (we need to know write permission to create but also to delete drafts record) $createok=1; $nbko=0; - if (GETPOST('action', 'aZ09') == 'create' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) + if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) { foreach ($featuresarray as $feature) { @@ -329,7 +329,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f // If a or and at least one ok if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; - if (GETPOST('action', 'aZ09') == 'create' && ! $createok) accessforbidden(); + if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden(); //print "Write access is ok"; } From 4fb8f6663a74b9d6268199e4ce0ed543986fd67a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 17:16:13 +0200 Subject: [PATCH 112/114] Fix code comment --- htdocs/core/class/fileupload.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index ee090fed65d..2f0ae34b529 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/ajax/fileupload.php + * \file htdocs/core/ajax/fileupload.class.php * \brief File to return Ajax response on file upload */ From 5ee9a88181094c2d4cc4f5eadf05a214a3abec31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 19:21:25 +0200 Subject: [PATCH 113/114] NEW Add anonymous telemetry --- htdocs/core/ajax/pingresult.php | 72 +++++++++++++++++++++++++++++++++ htdocs/main.inc.php | 49 ++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 htdocs/core/ajax/pingresult.php diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php new file mode 100644 index 00000000000..9b46546f5c3 --- /dev/null +++ b/htdocs/core/ajax/pingresult.php @@ -0,0 +1,72 @@ + + * + * 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 . + */ + +/** + * \file htdocs/core/ajax/pingresult.php + * \brief File to save result of anonymous ping + * Example: captureserver/public/index.php?action=dolibarrping + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$action=GETPOST('action', 'alpha'); +$hash_unique_id=GETPOST('hash_unique_id', 'alpha'); +$hash_algo=GETPOST('hash', 'alpha'); + + +// Security check +if (! empty($user->societe_id)) + $socid = $user->societe_id; + +$now = dol_now(); + + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +// If ok +if ($action == 'firstpingok') +{ + // Note: pings are by entities + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt')); + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id); + + print 'First ping OK saved for entity '.$conf->entity; +} +// If ko +elseif ($action == 'firstpingko') +{ + // Note: pings are by entities + dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); + print 'First ping KO saved for entity '.$conf->entity; +} +else { + print 'Error action='.$action.' not supported'; +} diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bf4c40a4176..96ddd9696a7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1124,6 +1124,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client); else header("Content-Type: ".$contenttype); + // Security options header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) if (! defined('XFRAMEOPTIONS_ALLOWALL')) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) @@ -2319,6 +2320,54 @@ if (! function_exists("llxFooter")) print "\n\n"; print ''."\n"; + // Add code for the fist asynchronous anonymous ping + if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) + { + if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) + || (! empty($conf->file->instance_unique_id) && $conf->file->instance_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) + || GETPOST('forceping', 'alpha')) + { + print "\n".''."\n"; + print "\n\n"; + ?> + + \n"; print "\n"; From a6fdec5713e8f06f3b72dca0fe15e997eee4915b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Aug 2019 20:11:55 +0200 Subject: [PATCH 114/114] Fix ping --- htdocs/main.inc.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 96ddd9696a7..ff599f7567f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2320,15 +2320,15 @@ if (! function_exists("llxFooter")) print "\n\n"; print ''."\n"; - // Add code for the fist asynchronous anonymous ping + // Add code for the asynchronous anonymous first ping (for telemetry) if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) { if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) - || (! empty($conf->file->instance_unique_id) && $conf->file->instance_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) + || (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID)) || GETPOST('forceping', 'alpha')) { - print "\n".''."\n"; - print "\n\n"; + print "\n".''."\n"; + print "\n\n"; ?>
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Type").'
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->datec,'dayhour').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->dateh, 'day').'