From 3036c94198d039e1ebc76c43928f3619d670172f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 7 Aug 2018 15:18:42 +0200 Subject: [PATCH 01/92] 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 0000000000000..cfee53da5f54c --- /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 4edce36b82f08..418339a0383de 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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; + $sql.= ", retained_waranty"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -458,6 +464,8 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function update(User $user, $notrigger=0) 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 @@ function update(User $user, $notrigger=0) $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 4e7fa86052943..c4ecbacf6e7fa 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 be072b8bacb43..2a429fc77658d 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 c0783a7bbd8c0..decd48f46bcfd 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 54194358748d1..94f0786343e3e 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 02/92] 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 cfee53da5f54c..ad6f858df20f5 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -81,7 +81,7 @@ _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 @@ '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 e411f8c5b1ba2..6415ef4cdcd04 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -288,6 +288,23 @@ 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 @@ $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 @@ 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 @@ function js_recalculate_revenuestamp(){ // 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 6415ef4cdcd04..c9e143049547f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -289,6 +289,21 @@ 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 @@ $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 @@ $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 @@ $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 @@ 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 '
'.($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 ''; + 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 418339a0383de..9c387f6630a98 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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function update(User $user, $notrigger=0) 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 @@ function update(User $user, $notrigger=0) $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 @@ public function hasDelay() 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 2a429fc77658d..fb7db22013896 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 decd48f46bcfd..abdefedc9443d 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 94f0786343e3e..c547f385be049 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 03/92] 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 ad6f858df20f5..dc3ec771b163f 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -76,6 +76,12 @@ print load_fiche_titre($langs->trans("InvoiceSituation"),'',''); $var=0; + +print '
'; +print ''; + +_updateBtn(); + print ''; @@ -94,17 +100,40 @@ +// 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 @@ print '
'; - print '
'; + print '
'; + print ''; if ($action != 'editretainedwarranty' && $user->rights->facture->creer){ @@ -3953,7 +4033,7 @@ 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 77/92] 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 61acf6e3a89ef..378d6087cc71d 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ } // 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 78/92] 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 e48fe32e4f006..4f525330e7973 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1683,7 +1683,7 @@ print ''; print ''; - print ''; + print ''; print ''; print "\n"; -print ''; -print ''; +print ''; @@ -134,23 +134,26 @@ 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 @@ } print '
'; - print ''; + + + + + if($displayWarranty) + { + // Retained Warranty payment date limit + print ''; + } + } @@ -4442,16 +4566,17 @@ function js_recalculate_revenuestamp(){ // 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 9c387f6630a98..e108b52657637 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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) // 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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function create(User $user, $notrigger=0, $forceduedate=0) $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $fetch_situation=false $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 @@ function update(User $user, $notrigger=0) $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 5e528f6a1d04c..37f61e01f3258 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1906,6 +1906,43 @@ function setPaymentTerms($id) 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 fb7db22013896..3eb266d355914 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 abdefedc9443d..f18ec0f521c23 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 c547f385be049..c9f966b2e2a5b 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 04/92] 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 c9e143049547f..b1d1116e54c3d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4079,7 +4079,7 @@ { 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 ba52759ea3530..ad650aca9b417 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 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) $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 c9f966b2e2a5b..95c1a87172a31 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 05/92] 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 b1d1116e54c3d..6f4796106c77f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4001,14 +4001,12 @@ } 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 06/92] 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 6f4796106c77f..4974bcb4a39c4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3129,7 +3129,7 @@ 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 @@ //print '
'.$langs->trans("PaypalAccount").'">'; } print '
'; + print ' + '; } } } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 58b076a953c20..a137b91236f24 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -147,6 +147,9 @@ 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 9fad375eade98..8999a73aaeac6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -376,6 +376,9 @@ 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 54/92] 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 8c9eb93004f03..02dc94285f683 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -430,7 +430,7 @@ '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 @@ 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 6b910236e96fb..c731637fce6b7 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -177,6 +177,7 @@ public function customerStripe(Societe $object, $key = '', $status = 0, $createi } 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 55/92] 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 02dc94285f683..e43089f0a8de1 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -459,7 +459,7 @@ 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 56/92] Fix error management --- htdocs/public/payment/newpayment.php | 78 +++++++++++++++------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index e43089f0a8de1..0a967cb10a796 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -461,47 +461,51 @@ $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)) - { - $error++; - dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to create card record', null, 'errors'); - $action=''; - } - else + if (! $error) { - 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=''; - } + if ($savesource) { + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { + $card = $stripeToken; + } + + 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 57/92] 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 4cc935f95a2f1..2d9795e6f597d 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1181,7 +1181,6 @@ public function setValidate($fuser, $notrigger = 0) } } } - } } From ecc0b4ed32a13646fcfb277dbd5c1ef0531889b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Jul 2019 02:16:21 +0200 Subject: [PATCH 58/92] 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 39ed6162f0f18..bcb727f1fcb7b 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -56,11 +56,12 @@ 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_endmonth = $tmp['mon']; $date_endyear = $tmp['year']; +$arrayfields=array(); + /* * Actions @@ -108,6 +111,7 @@ $search_user=''; $search_desc=''; $search_ua=''; + $search_prefix_session=''; } // Purge audit events @@ -136,6 +140,7 @@ $securityevent->type='SECURITY_EVENTS_PURGE'; $securityevent->dateevent=$now; $securityevent->description=$text; + $result=$securityevent->create($user); if ($result > 0) { @@ -163,7 +168,7 @@ $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_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 ($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 @@ 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 @@ 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 af87e25fad1ca..57a076963fd61 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 @@ public function create($user) $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 @@ public function create($user) $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 @@ public function fetch($id, $user = null) $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 @@ public function fetch($id, $user = null) $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 @@ public function initAsSpecimen() $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 59/92] 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 21e43b524d75f..67633e828a587 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -472,14 +472,15 @@ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_la */ 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 @@ public function createStd(User $user, $notrigger = false, $mode='') $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 60/92] 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 f0d8df454cfd9..a86975b606f04 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1161,7 +1161,7 @@ function initfieldrequired() } // 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 61/92] 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 373e8b953f6e5..c6ec8569a0994 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1181,7 +1181,7 @@ function initfieldrequired() } // 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 19790159c2211..4251ba45ab98e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -342,7 +342,7 @@ // 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 @@ // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; From 56f124844c353306307728f17eb3ba211a8710b9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 29 Jul 2019 10:04:28 +0200 Subject: [PATCH 62/92] 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 1b477a57ae9bc..904388db64ddb 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -938,20 +938,14 @@ public function exportLDCompta($objectLines) $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 @@ public function exportLDCompta($objectLines) $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 @@ public function exportLDCompta($objectLines) } 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 63/92] 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 dd861d5dc4767..40b4e89dfc5c5 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -584,8 +584,8 @@ public function valid($user, $notrigger = 0) 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 5de2c9b23f540..d957235d9674c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1809,8 +1809,8 @@ public function valid($user, $notrigger = 0) 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 d0e0addbc94c0..15156688603cc 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -425,8 +425,8 @@ public function valid($user, $idwarehouse = 0, $notrigger = 0) 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 2a9a4f5686d3a..216282d369ebb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2419,8 +2419,8 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger 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 0b08d3723da9c..bfc18faf12353 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -487,8 +487,8 @@ public function validate(User $user, $force_number = '', $notrigger = 0) 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 37f191a0ab043..3205a245285b3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -814,8 +814,8 @@ public function valid($user, $notrigger = 0) 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 2d9795e6f597d..63b0b798a298e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1152,8 +1152,8 @@ public function setValidate($fuser, $notrigger = 0) 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 ce066fc8c1197..c987e6ffc58c0 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -577,8 +577,8 @@ public function setValid($user, $notrigger = 0) 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 b32e90c311df8..c85bfaaf2d34a 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -552,8 +552,8 @@ public function valid($user, $idwarehouse = 0, $notrigger = 0) 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 b13925bf29dd8..31780d33ed51b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1420,8 +1420,8 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger 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 f24a2aee71335..88cf4e1355abd 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -442,8 +442,8 @@ public function valid($user) 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 84f95e40b9a56..e89eb2c595b0f 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -644,8 +644,8 @@ public function valid($user, $notrigger = 0) 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 786485ad6ddf4..cb4f774a9510d 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1485,8 +1485,8 @@ public function valid($user, $notrigger = 0) 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 64/92] 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 d185b4cfcf709..4a873847d8a8e 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -393,7 +393,7 @@ public function get_code($db, $societe, $type = '') * @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 65/92] 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 40b4e89dfc5c5..7ad86b59ae841 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -585,7 +585,7 @@ public function valid($user, $notrigger = 0) { // 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 d957235d9674c..a9746ca6f656d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1810,7 +1810,7 @@ public function valid($user, $notrigger = 0) { // 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 15156688603cc..434d43e8ffa19 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -426,7 +426,7 @@ public function valid($user, $idwarehouse = 0, $notrigger = 0) { // 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 216282d369ebb..a8b75341ed3a1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2420,7 +2420,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger { // 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 bfc18faf12353..147d31311d31b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -488,7 +488,7 @@ public function validate(User $user, $force_number = '', $notrigger = 0) { // 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 3205a245285b3..7fc4def441bb2 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -815,7 +815,7 @@ public function valid($user, $notrigger = 0) { // 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 63b0b798a298e..1160a6dcb94b3 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1153,7 +1153,7 @@ public function setValidate($fuser, $notrigger = 0) // 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 c987e6ffc58c0..4ce2aa954b2b4 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -578,7 +578,7 @@ public function setValid($user, $notrigger = 0) // 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 c85bfaaf2d34a..d15545e4cdab9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -553,7 +553,7 @@ public function valid($user, $idwarehouse = 0, $notrigger = 0) { // 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 31780d33ed51b..9fe2f9bf6ed40 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1421,7 +1421,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger { // 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 88cf4e1355abd..a8eee72df337e 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -443,7 +443,7 @@ public function valid($user) { // 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 e89eb2c595b0f..3e2776675a147 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -645,7 +645,7 @@ public function valid($user, $notrigger = 0) { // 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 cb4f774a9510d..481d80cab57e1 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1486,7 +1486,7 @@ public function valid($user, $notrigger = 0) { // 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 66/92] 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 ae9ef67f755dd..326d378a1994f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1586,9 +1586,9 @@ 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 @@ $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 @@ 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 67/92] 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 904388db64ddb..10ebabc4f8a23 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -938,15 +938,22 @@ public function exportLDCompta($objectLines) $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 @@ public function exportLDCompta($objectLines) $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 @@ public function exportLDCompta($objectLines) $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 68/92] 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 2e4085200a2c2..e2e0e0eb0eeff 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 @@ $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'))) - { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); - } - else + // 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_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 69/92] 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 770678aae15ad..c2b2143f2774f 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -55,6 +55,9 @@ 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 (! $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 70/92] Try to use the new scrutinizer engine --- .scrutinizer.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index b48aa158ccec5..85809bcc05833 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 71/92] 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 61acf6e3a89ef..378d6087cc71d 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ } // 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 72/92] 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 a6473eaeb8e94..776d8dfa04fcd 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -493,15 +493,24 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma 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 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma 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 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma } // 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 7f222f523cae5..d58fd16cf2f51 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -519,15 +519,24 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma 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 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma 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 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma } // 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 5007477995525..668b0ac901472 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -422,8 +422,8 @@ function __construct($db) $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 @@ function __construct($db) $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 @@ function __construct($db) $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 73/92] 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 073aaa9fb2454..3db6e9fb8031d 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -170,7 +170,9 @@ function llxFooter() 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 74/92] 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 30b3ff7d64f54..a53e5f07ee7fc 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -451,6 +451,11 @@ $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 75/92] 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 776d8dfa04fcd..e0ec89379af3e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -497,7 +497,7 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma { $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 d58fd16cf2f51..7d850ccfb8bc4 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -523,7 +523,7 @@ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$ma { $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 76/92] 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 34784beefcb9a..3f7b97fee7300 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -383,7 +383,7 @@ } 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 @@ function init_supplier_categ() { // 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 79/92] 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 bf46ecb989029..ebb9e8a41ac3d 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -255,6 +255,25 @@ { $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 80/92] 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 ebb9e8a41ac3d..75c6f72e1df81 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -256,7 +256,7 @@ $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 a9746ca6f656d..7a24fad83af6f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3506,7 +3506,7 @@ public function getNextNumRef($soc) 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 6bb47f12a128c..0fd061ac7ed50 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2591,7 +2591,7 @@ } } 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 a8b75341ed3a1..13bc74bc6f14b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3452,7 +3452,7 @@ public function getNextNumRef($soc, $mode = 'next') 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 d9a912ea50bda..26e3f2792d6e8 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -489,7 +489,7 @@ public function getNextNumRef($mode = 'next') 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 a3c79d2360257..614782c519b48 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1141,7 +1141,7 @@ public function getNextNumRef($soc, $mode = 'next') 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 d0c69fbe61b2d..ddbec62e41394 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -78,7 +78,7 @@ // $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 @@ 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 4e2c4e2d3a5c6..1be716f8f61ea 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -58,7 +58,7 @@ 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 147d31311d31b..e81febde6dfdd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -245,7 +245,7 @@ public function getNextNumRef($soc) 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 45ad69f6c6491..b48fef9759a5c 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -701,7 +701,7 @@ public function getNextNumRef($soc, $mode = 'next') 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 8e4d42559a821..4c8e761da9aa0 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 1cf435379cd5d..a223f936638bc 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 0a967cb10a796..a9e712c92db03 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1928,7 +1928,8 @@ // 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 c9275293bb207..964812a05a3a4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -224,21 +224,25 @@ * 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 b952285747ba3..0a91e303a53ef 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 @@ { 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 @@ 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 @@ 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 79c7eee3d56ab..e09c31664cd79 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -42,7 +42,7 @@ $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 @@ function fail($message) $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 702bb08271454..dba42a105aeca 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 @@ function TerminalsDialog() $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 @@ function TerminalsDialog() } } 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 46e42c351c779..2ad328b5a88b7 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -120,7 +120,7 @@ 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 (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 90/92] 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 818514868c2e0..060ddc36ff344 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -218,17 +218,16 @@ private function getCommon($id = 0, $track_id = '', $ref = '') * 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 @@ public function index($socid = 0, $mode = "", $sortfield = "s.rowid", $sortorder $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 @@ public function index($socid = 0, $mode = "", $sortfield = "s.rowid", $sortorder * * @param array $request_data Request datas * @return int ID of ticket - * */ public function post($request_data = null) { @@ -364,9 +336,11 @@ public function post($request_data = null) 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 @@ protected function _cleanObjectDatas($object) "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 91/92] 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 7f4a167edd9af..99c6cea7b3999 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -37,12 +37,12 @@ /* * 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 92/92] 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 ea0c645348694..f58095e15588f 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 26b449ff03961..bed9cff5722f5 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 8dca764d7d1e8..7d1b681c087d9 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 b22907d080c64..08c99ad1b68e2 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 2f6ccfbf67b3a..e893cfcda90b8 100644 --- a/htdocs/includes/stripe/init.php +++ b/htdocs/includes/stripe/init.php @@ -76,6 +76,7 @@ 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/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/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 0e84951dcd08b..1adc6b79d53ba 100644 --- a/htdocs/includes/stripe/lib/Account.php +++ b/htdocs/includes/stripe/lib/Account.php @@ -152,8 +152,8 @@ public function deauthorize($clientId = null, $opts = null) /** - * @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 @@ public static function retrieveCapability($id, $capabilityId, $params = null, $o } /** - * @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 @@ public static function updateCapability($id, $capabilityId, $params = null, $opt } /** - * @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 @@ public static function allCapabilities($id, $params = null, $opts = null) } /** - * @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 @@ public static function createExternalAccount($id, $params = null, $opts = null) } /** - * @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 @@ public static function retrieveExternalAccount($id, $externalAccountId, $params } /** - * @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 @@ public static function updateExternalAccount($id, $externalAccountId, $params = } /** - * @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 @@ public static function deleteExternalAccount($id, $externalAccountId, $params = } /** - * @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 @@ public static function allExternalAccounts($id, $params = null, $opts = null) } /** - * @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 @@ public function persons($params = null, $options = null) } /** - * @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 @@ public static function createPerson($id, $params = null, $opts = null) } /** - * @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 @@ public static function retrievePerson($id, $personId, $params = null, $opts = nu } /** - * @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 @@ public static function updatePerson($id, $personId, $params = null, $opts = null } /** - * @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 @@ public static function deletePerson($id, $personId, $params = null, $opts = null } /** - * @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 cd9b79ae67549..403c4aa173e74 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 019a4d87cbda8..3fdc9188c648f 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 832a07c7c042d..43274c5559c2b 100644 --- a/htdocs/includes/stripe/lib/Charge.php +++ b/htdocs/includes/stripe/lib/Charge.php @@ -11,7 +11,9 @@ * @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 @@ * @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 968d58cf632a9..33fc6a08ab29b 100644 --- a/htdocs/includes/stripe/lib/Checkout/Session.php +++ b/htdocs/includes/stripe/lib/Checkout/Session.php @@ -15,6 +15,7 @@ * @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 169ed0815c3d2..66351ffb82877 100644 --- a/htdocs/includes/stripe/lib/CreditNote.php +++ b/htdocs/includes/stripe/lib/CreditNote.php @@ -8,6 +8,7 @@ * @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 44f5e6e2f091b..6e78f981ee412 100644 --- a/htdocs/includes/stripe/lib/Customer.php +++ b/htdocs/includes/stripe/lib/Customer.php @@ -7,8 +7,8 @@ * * @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 @@ * @property mixed $shipping * @property Collection $sources * @property Collection $subscriptions + * @property string $tax_exempt * @property Collection $tax_ids * * @package Stripe @@ -61,6 +62,7 @@ public static function getSavedNestedResources() return $savedNestedResources; } + const PATH_BALANCE_TRANSACTIONS = '/balance_transactions'; const PATH_SOURCES = '/sources'; const PATH_TAX_IDS = '/tax_ids'; @@ -264,4 +266,55 @@ public static function allTaxIds($id, $params = null, $opts = null) { 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 0000000000000..06cafcd45c624 --- /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 31b7cf77bbad3..1e2c8c7356591 100644 --- a/htdocs/includes/stripe/lib/Source.php +++ b/htdocs/includes/stripe/lib/Source.php @@ -18,6 +18,7 @@ * @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 027f22fd83ce0..2397ef9c418ca 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 8b57d46b6256a..f5a46171d81e9 100644 --- a/htdocs/includes/stripe/lib/Subscription.php +++ b/htdocs/includes/stripe/lib/Subscription.php @@ -13,6 +13,7 @@ * @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 @@ * @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 2993e2d1375bc..0f72a2ac95f33 100644 --- a/htdocs/includes/stripe/lib/TaxId.php +++ b/htdocs/includes/stripe/lib/TaxId.php @@ -12,7 +12,6 @@ * @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 e21d45dac1684..f9f15440023b6 100644 --- a/htdocs/includes/stripe/lib/Util/Util.php +++ b/htdocs/includes/stripe/lib/Util/Util.php @@ -88,6 +88,7 @@ public static function convertToStripeObject($resp, $opts) \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 @@ public static function convertToStripeObject($resp, $opts) \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 @@ public static function convertToStripeObject($resp, $opts) \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 e0ab3021a8987..45c7dc0f30a02 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 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance } $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 73e70dbd7dee3..9f8be8777b34d 100644 --- a/htdocs/includes/stripe/lib/WebhookSignature.php +++ b/htdocs/includes/stripe/lib/WebhookSignature.php @@ -60,7 +60,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul } // 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,