diff --git a/.scrutinizer.yml b/.scrutinizer.yml index b48aa158cce..85809bcc058 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,12 @@ # .scrutinizer.yml #build: # - php-scrutinizer-run +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run imports: - javascript diff --git a/COPYRIGHT b/COPYRIGHT index ea0c6453486..f58095e1558 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -32,7 +32,7 @@ PSR/simple-cache ? Library for cache (used by PHPSp Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Sabre 3.2.2 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP -Stripe 6.35 MIT licence Yes Library for Stripe module +Stripe 6.41 MIT licence Yes Library for Stripe module TCPDF 6.2.25 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index b0adb2e2ad1..0328eba010c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php $langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' @@ -346,6 +347,8 @@ if ($action == 'create') } print '
'; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -441,7 +444,8 @@ if ($action == 'create') print ''; if ($action == 'editdate') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); @@ -464,7 +468,8 @@ if ($action == 'create') print ''; if ($action == 'editjournal') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); @@ -487,7 +492,8 @@ if ($action == 'create') print ''; if ($action == 'editdocref') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print ''; @@ -583,6 +589,8 @@ if ($action == 'create') print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print ''; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -641,8 +649,8 @@ if ($action == 'create') print '' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . ''; print '' . length_accounta($line->subledger_account) . ''; print '' . $line->label_operation. ''; - print '' . price($line->debit) . ''; - print '' . price($line->credit) . ''; + print '' . price($line->debit) . ''; + print '' . price($line->credit) . ''; print ''; print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; @@ -675,7 +683,7 @@ if ($action == 'create') print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, ''); print ''; print ''; - // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 616c8697c61..aecd5a1d82e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -789,7 +789,7 @@ if ($num > 0) // Amount debit if (! empty($arrayfields['t.debit']['checked'])) { - print '' . ($line->debit ? price($line->debit) : ''). ''; + print '' . ($line->debit ? price($line->debit) : ''). ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield']; $totalarray['totaldebit'] += $line->debit; @@ -798,7 +798,7 @@ if ($num > 0) // Amount credit if (! empty($arrayfields['t.credit']['checked'])) { - print '' . ($line->credit ? price($line->credit) : '') . ''; + print '' . ($line->credit ? price($line->credit) : '') . ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield']; $totalarray['totalcredit'] += $line->credit; @@ -879,8 +879,8 @@ if ($num > 0) if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; } - elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).''; - elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).''; + elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).''; + elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).''; else print ''; } $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3169d3737d9..b4f420b262c 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2018 Alexandre Spangaro + * Copyright (C) 2016-2019 Alexandre Spangaro * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz * Copyright (C) 2017-2019 Frédéric France @@ -48,8 +48,10 @@ class AccountancyExport public static $EXPORT_TYPE_BOB50 = 35; public static $EXPORT_TYPE_CIEL = 40; public static $EXPORT_TYPE_SAGE50_SWISS = 45; + public static $EXPORT_TYPE_CHARLEMAGNE = 50; public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_OPENCONCERTO = 100; + public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_FEC = 1000; @@ -105,7 +107,9 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), + self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), ); ksort($listofexporttypes, SORT_NUMERIC); @@ -133,6 +137,7 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -191,10 +196,18 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), + self::$EXPORT_TYPE_CHARLEMAGNE => array( + 'label' => $langs->trans('Modelcsv_charlemagne'), + 'ACCOUNTING_EXPORT_FORMAT' => 'txt', + ), ), 'cr'=> array ( '1' => $langs->trans("Unix"), @@ -257,12 +270,18 @@ class AccountancyExport case self::$EXPORT_TYPE_OPENCONCERTO : $this->exportOpenConcerto($TData); break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; case self::$EXPORT_TYPE_SAGE50_SWISS : $this->exportSAGE50SWISS($TData); break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; + case self::$EXPORT_TYPE_CHARLEMAGNE : + $this->exportCharlemagne($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -274,7 +293,6 @@ class AccountancyExport * Export format : CEGID * * @param array $objectLines data - * * @return void */ public function exportCegid($objectLines) @@ -300,7 +318,6 @@ class AccountancyExport * Export format : COGILOG * * @param array $objectLines data - * * @return void */ public function exportCogilog($objectLines) @@ -334,7 +351,6 @@ class AccountancyExport * Export format : COALA * * @param array $objectLines data - * * @return void */ public function exportCoala($objectLines) @@ -362,7 +378,6 @@ class AccountancyExport * Export format : BOB50 * * @param array $objectLines data - * * @return void */ public function exportBob50($objectLines) @@ -401,7 +416,6 @@ class AccountancyExport * Export format : CIEL * * @param array $TData data - * * @return void */ public function exportCiel(&$TData) @@ -442,7 +456,6 @@ class AccountancyExport * Export format : Quadratus * * @param array $TData data - * * @return void */ public function exportQuadratus(&$TData) @@ -526,7 +539,6 @@ class AccountancyExport * Export format : EBP * * @param array $objectLines data - * * @return void */ public function exportEbp($objectLines) @@ -563,7 +575,6 @@ class AccountancyExport * Export format : Agiris Isacompta * * @param array $objectLines data - * * @return void */ public function exportAgiris($objectLines) @@ -604,7 +615,6 @@ class AccountancyExport * Export format : OpenConcerto * * @param array $objectLines data - * * @return void */ public function exportOpenConcerto($objectLines) @@ -634,16 +644,17 @@ class AccountancyExport } /** - * Export format : Configurable + * Export format : Configurable CSV * * @param array $objectLines data - * * @return void */ public function exportConfigurable($objectLines) { global $conf; + $separator = $this->separator; + foreach ($objectLines as $line) { $tab = array(); // export configurable @@ -651,15 +662,14 @@ class AccountancyExport $tab[] = $line->piece_num; $tab[] = $date; $tab[] = $line->doc_ref; - $tab[] = $line->label_operation; + $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation; $tab[] = length_accountg($line->numero_compte); $tab[] = length_accounta($line->subledger_account); - $tab[] = price($line->debit); - $tab[] = price($line->credit); - $tab[] = price($line->montant); + $tab[] = price2num($line->debit); + $tab[] = price2num($line->credit); + $tab[] = price2num($line->montant); $tab[] = $line->code_journal; - $separator = $this->separator; print implode($separator, $tab) . $this->end_line; } } @@ -668,7 +678,6 @@ class AccountancyExport * Export format : FEC * * @param array $objectLines data - * * @return void */ public function exportFEC($objectLines) @@ -909,6 +918,162 @@ class AccountancyExport } } + /** + * Export format : LD Compta version 9 & higher + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf + * + * @param array $objectLines data + * + * @return void + */ + public function exportLDCompta($objectLines) + { + + $separator = ';'; + $end_line = "\n"; + + foreach ($objectLines as $line) { + + $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'; + } else { + $nature_piece = 'FF'; + } + } elseif ($line->doc_type == 'customer_invoice') { + if ($line->montant < 0) { + $nature_piece = 'AC'; + } else { + $nature_piece = 'FC'; + } + } else { + $nature_piece = ''; + } + print $nature_piece . $separator; + // RACI + /* + if (! empty($line->subledger_account)) { + 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; + } 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)) { + print 'C'; + } else { + print ''; + } + print $end_line; + } + } + + /** + * Export format : Charlemagne + * + * @param array $objectLines data + * + * @return void + */ + public function exportCharlemagne($objectLines) + { + global $langs; + $langs->load('compta'); + + $separator = "\t"; + $end_line = "\n"; + + /* + * Charlemagne export need header + */ + print $langs->transnoentitiesnoconv('Date') . $separator; + print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator; + print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator; + print $langs->transnoentitiesnoconv('Amount') . $separator; + print 'S' . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator; + print $end_line; + + foreach($objectLines as $line) { + + $date = dol_print_date($line->doc_date, '%Y%m%d'); + print $date . $separator; //Date + + print self::trunc($line->code_journal, 6) . $separator; //Journal code + + if(!empty($line->subledger_account)) $account = $line->subledger_account; + else $account = $line->numero_compte; + print self::trunc($account, 15) . $separator;//Account number + + print self::trunc($line->label_compte, 60) . $separator;//Account label + print self::trunc($line->doc_ref, 20) . $separator;//Piece + print self::trunc($line->label_operation, 60) . $separator;//Operation label + print price(abs($line->montant)) . $separator;//Amount + print $line->sens . $separator;//Direction + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $separator;//Analytic + print $end_line; + + } + } + + /** * trunc * diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 7e7f40ddfbb..8e1f36bbf41 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -469,14 +469,15 @@ class BookKeeping extends CommonObject */ public function createStd(User $user, $notrigger = false, $mode = '') { - global $conf; + global $conf, $langs; + + $langs->loadLangs(array("accountancy", "bills", "compta")); dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; // Clean parameters - if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -540,7 +541,7 @@ class BookKeeping extends CommonObject $now = dol_now(); // Check parameters - // Put here code to add control on parameters values + $this->journal_label = $langs->trans($this->journal_label); // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6138fd395f0..a6fd91a4210 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1187,7 +1187,7 @@ else } // Morphy $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy)); print ""; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 71660c0cd8c..571879788ee 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -53,21 +53,21 @@ class Subscription extends CommonObject * @var integer */ public $datec; - + /** * Date modification record (tms) * * @var integer */ public $datem; - + /** * Subscription start date (date subscription) * * @var integer */ public $dateh; - + /** * Subscription end date * @@ -128,10 +128,11 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == null) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + + if ($this->fk_type == null) { // If type not defined, we use the type of member $type=$member->typeid; } else { $type=$this->fk_type; @@ -151,11 +152,13 @@ class Subscription extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->fk_type = $type; } if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers @@ -257,7 +260,8 @@ class Subscription extends CommonObject $result=$member->update_end_date($user); if (! $error && ! $notrigger) { - // Call triggers + $this->context = array('member'=>$member); + // Call triggers $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index f17638a9966..1d890ab580f 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -182,7 +182,7 @@ if ($result > 0) if (empty($dn)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete").''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; } else { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index a8478f35e88..e44995b263f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2019 Laurent Destailleur * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -205,18 +205,18 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print $form->showrefnav($object, 'rowid', $linkback, 1); print ''; - // Type + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').''; + print ''; + + // Type print ''; print ''.$langs->trans("Type").''; print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); print''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').''; - print ''; - // Date start subscription print ''.$langs->trans("DateSubscription").''; print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); @@ -309,6 +309,12 @@ if ($rowid && $action != 'edit') print ''; + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; + // Type print ''; print ''; @@ -322,17 +328,6 @@ if ($rowid && $action != 'edit') } print ''; - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; - - // Date record - /*print ''; - print ''; - print '';*/ - // Date subscription print ''; print ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 2c8c108b3d5..96b043fcf7b 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -342,7 +342,7 @@ if ($action == 'create') // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; @@ -775,7 +775,7 @@ if ($rowid > 0) // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print '"; diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 7f4a167edd9..99c6cea7b39 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -37,12 +37,12 @@ $action = GETPOST('action', 'aZ09'); /* * Actions */ - + if ($action == 'setvalue' && $user->admin) { - $result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); - + $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + if ($result1 >= 0 && $result2 >= 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php new file mode 100644 index 00000000000..0e62029e8f2 --- /dev/null +++ b/htdocs/admin/facture_situation.php @@ -0,0 +1,228 @@ + + * 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 ''; + +_updateBtn(); + +print '
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Type").'
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->datec,'dayhour').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->dateh, 'day').'
'.$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 "
'; + + +_printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices')); +_printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote')); +_printOnOff('INVOICE_USE_SITUATION_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); + +$metas = array( + 'type' => 'number', + 'step' => '0.01', + 'min' => 0, + 'max' => 100 +); +_printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas); + + + + +// 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(); + +/** + * Print an update button + * + * @return void + */ +function _updateBtn() +{ + global $langs; + print '
'; + print ''; + print '
'; +} + +/** + * Print a On/Off button + * + * @param string $confkey the conf key + * @param bool $title Title of conf + * @param string $desc Description + * + * @return void + */ +function _printOnOff($confkey, $title = false, $desc = '') +{ + global $var, $bc, $langs; + $var=!$var; + print ''; + print ''.($title?$title:$langs->trans($confkey)); + if (!empty($desc)) { + print '
'.$langs->trans($desc).''; + } + print ''; + print ' '; + print ''; + print ajax_constantonoff($confkey); + print ''; +} + + +/** + * Print a form part + * + * @param string $confkey the conf key + * @param bool $title Title of conf + * @param string $desc Description of + * @param array $metas html meta + * @param string $type type of input textarea or input + * @param bool $help help description + * + * @return void + */ +function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false) +{ + global $var, $bc, $langs, $conf, $db, $inputCount; + $var=!$var; + $inputCount = empty($inputCount)?1:($inputCount+1); + $form=new Form($db); + + $defaultMetas = array( + 'name' => 'value'.$inputCount + ); + + 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 ''; + + 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 ''; + + print ''; + if ($type=='textarea') { + print ''; + } else { + print ''; + } + print ''; +} diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index e63aec50dca..c06314daa9a 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -446,8 +446,10 @@ print "\n";
-
" id="buttonGo" />
+
+ " id="buttonGo"> + +

'.$langs->trans("BackupResult").': '; print $_SESSION["commandbackupresult"]; @@ -598,9 +600,6 @@ print '
'; - - - admin) accessforbidden(); if ($file && ! $what) { //print DOL_URL_ROOT.'/dolibarr_export.php'; - header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod")))); + header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int')?'&page_y='.GETPOST('page_y', 'int'):'')); exit; } @@ -122,25 +122,15 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); - $ok=0; dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - foreach($arrayofallowedcommand as $allowedcommand) - { - $basenamecmddump=basename($cmddump); - if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command - { - $ok=1; - break; - } - } - if (! $ok) + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command { $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); } @@ -176,6 +166,18 @@ if ($what == 'postgresql') $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); + /* Not required, the command is output on screen but not ran for pgsql + if (! empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); + } + } */ + if (! $errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); @@ -193,7 +195,6 @@ if ($what == 'postgresql') } - if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); @@ -230,8 +231,8 @@ $result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/ print '
'; */ -// Redirect t backup page -header("Location: dolibarr_export.php"); +// Redirect to backup page +header("Location: dolibarr_export.php".(GETPOST('page_y', 'int')?'?page_y='.GETPOST('page_y', 'int'):'')); $time_end = time(); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 39ed6162f0f..bcb727f1fcb 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -56,11 +56,12 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="dateevent"; if (! $sortorder) $sortorder="DESC"; -$search_code = GETPOST("search_code"); -$search_ip = GETPOST("search_ip"); -$search_user = GETPOST("search_user"); -$search_desc = GETPOST("search_desc"); -$search_ua = GETPOST("search_ua"); +$search_code = GETPOST("search_code", "alpha"); +$search_ip = GETPOST("search_ip", "alpha"); +$search_user = GETPOST("search_user", "alpha"); +$search_desc = GETPOST("search_desc", "alpha"); +$search_ua = GETPOST("search_ua", "none"); +$search_prefix_session = GETPOST("search_prefix_session", "none"); if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); else $date_start=-1; @@ -91,6 +92,8 @@ $date_endday = $tmp['mday']; $date_endmonth = $tmp['mon']; $date_endyear = $tmp['year']; +$arrayfields=array(); + /* * Actions @@ -108,6 +111,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_user=''; $search_desc=''; $search_ua=''; + $search_prefix_session=''; } // Purge audit events @@ -136,6 +140,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $securityevent->type='SECURITY_EVENTS_PURGE'; $securityevent->dateevent=$now; $securityevent->description=$text; + $result=$securityevent->create($user); if ($result > 0) { @@ -163,7 +168,7 @@ $userstatic=new User($db); $usefilter=0; $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,"; -$sql.= " e.fk_user, e.description,"; +$sql.= " e.fk_user, e.description, e.prefix_session,"; $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; @@ -175,6 +180,7 @@ if ($search_ip) { $usefilter++; $sql.=natural_search("e.ip", $search_ip, 0); } if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); } if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); } if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); } +if ($search_prefix_session) { $usefilter++; $sql.=natural_search("e.prefix_session", $search_prefix_session, 0); } $sql.= $db->order($sortfield, $sortorder); // Count total nb of records @@ -207,6 +213,7 @@ if ($result) if ($search_user) $param.='&search_user='.urlencode($search_user); if ($search_desc) $param.='&search_desc='.urlencode($search_desc); if ($search_ua) $param.='&search_ua='.urlencode($search_ua); + if ($search_prefix_sessiona) $param.='&search_prefix_session='.urlencode($search_prefix_session); if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth); if ($date_startday) $param.= "&date_startday=".urlencode($date_startday); if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear); @@ -239,22 +246,36 @@ if ($result) print ''.$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 ''; // IP print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - //print ''; + //print ''; print ''; + if (! empty($arrayfields['e.user_agent']['checked'])) + { + print ''; + print ''; + print ''; + } + + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + print ''; + print ''; + print ''; + } + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -264,11 +285,19 @@ if ($result) print ''; - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, 'align="left"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['e.user_agent']['checked'])) + { + print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); + } print_liste_field_titre(''); print "\n"; @@ -312,9 +341,26 @@ if ($result) print $text; print ''; + if (! empty($arrayfields['e.user_agent']['checked'])) + { + // User agent + print ''; + print $obj->user_agent; + print ''; + } + + if (! empty($arrayfields['e.prefix_session']['checked'])) + { + // User agent + print ''; + print $obj->prefix_session; + print ''; + } + // More informations 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 ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 10601303a61..7ad86b59ae8 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -515,6 +515,7 @@ class BOM extends CommonObject public function valid($user, $notrigger = 0) { global $conf, $langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; @@ -582,13 +583,18 @@ class BOM extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) - // in order not to lose the attachments - $oldref = dol_sanitizeFileName($this->ref); + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->bom->dir_output.'/'.$oldref; $dirdest = $conf->bom->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index 05117f5e7cb..bb0e037bf7d 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -79,16 +79,6 @@ if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_ } -/* -if (! empty($_POST['txtUsername']) && ! empty($conf->banque->enabled) && (empty($conf_fkaccount_cash) && empty($conf_fkaccount_cheque) && empty($conf_fkaccount_cb))) -{ - $langs->load("errors"); - $retour=$langs->trans("ErrorModuleSetupNotComplete"); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); - exit; -} -*/ - // Check password $auth = new Auth($db); $retour = $auth->verif($username, $password); diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 8da535f20f3..4230227717e 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -165,7 +165,7 @@ $langs->loadLangs(array("main","bills","cashdesk")); if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) { $langs->load("errors"); - print ''; + print 'transnoentitiesnoconv("CashDesk"))).'" />'; } else print ''; print '
'; @@ -173,7 +173,7 @@ $langs->loadLangs(array("main","bills","cashdesk")); if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); - print ''; + print 'transnoentitiesnoconv("CashDesk"))).'" />'; } else print ''; print '
'; @@ -181,7 +181,7 @@ $langs->loadLangs(array("main","bills","cashdesk")); if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); - print ''; + print 'transnoentitiesnoconv("CashDesk")).'" />'; } else print ''; print ''; diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index b0f1f5253c2..429e5398c5a 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -168,287 +168,8 @@ if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5p //var_dump($objectpage);exit; print '
'; -if (count($object->records) > 0) -{ - // ***** Part for web sites - - print '
'; - print $langs->trans("WebSite").': '; - print '
'; - - // List of websites - print '
'; - $out=''; - $out.=''; - $out.=ajax_combobox('website'); - print $out; - print ''; - - if ($website) - { - $virtualurl=''; - $dataroot=DOL_DATA_ROOT.'/collab/'.$website; - if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; - } - - if ($website && $action == 'preview') - { - $disabled=''; - if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; - - print '   '; - - //print ''; - print ''; - print ''; - print ''; - } - - print '
'; - - // Button for websites - print '
'; - - if ($action == 'preview') - { - print '
'; - print ''; - //print ''; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); - print $form->textwithpicto('', $htmltext); - print '
'; - - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/collab/index.php?website='.$website; - //if (! empty($object->virtualhost)) - //{ - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - //} - - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); - print ''; - } - - if (in_array($action, array('editcss','editmenu','create'))) - { - if ($action != 'preview') print ''; - if (preg_match('/^create/', $action)) print ''; - if (preg_match('/^edit/', $action)) print ''; - } - - print '
'; - // ***** Part for pages - - if ($website) - { - print '
'; - - $array=$objectpage->fetchAll($object->id); - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); - $atleastonepage=(is_array($array) && count($array) > 0); - - print '
'; - print '
'; - print $langs->trans("Page").': '; - print '
'; - print '
'; - - if ($action != 'add') - { - $out=''; - $out.=''; - $out.=ajax_combobox('pageid'); - print $out; - } - else - { - print $langs->trans("New"); - } - - print ''; - //print $form->selectarray('page', $array); - - if ($action == 'preview') - { - $disabled=''; - if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; - - if ($pageid > 0) - { - print '   '; - - if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; - else print ''; - print ''; - print ''; - //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; - //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; - print ''; - } - } - - print '
'; - print '
'; - print '
'; - - print '
'; - - if ($website && $pageid > 0 && $action == 'preview') - { - $websitepage = new WebSitePage($db); - $websitepage->fetch($pageid); - - $realpage=$urlwithroot.'/public/collab/index.php?website='.$website.'&page='.$pageid; - $pagealias = $websitepage->pageurl; - - print '
'; - print ''; - //print ''; - $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); - print $form->textwithpicto('', $htmltext); - print '
'; - - if (! empty($object->virtualhost)) - { - $urlext=$virtualurl.'/'.$pagealias.'.php'; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - } - else - { - print ''; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); - print ''; - } - - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); - print ''; // View page in new Tab - //print ''; - - // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext - } - if (! in_array($action, array('editcss','editmenu','create'))) - { - if ($action != 'preview') print ''; - if (preg_match('/^create/', $action)) print ''; - if (preg_match('/^edit/', $action)) print ''; - } - - print '
'; - - if ($action == 'preview') - { - // Adding jquery code to change on the fly url of preview ext - if (! empty($conf->use_javascript_ajax)) - { - print ''; - } - } - } -} -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 0c1cd1f1830..5faa94f2d08 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1749,10 +1749,10 @@ class Propal extends CommonObject */ public function valid($user, $notrigger = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $error=0; // Protection @@ -1818,14 +1818,18 @@ class Propal extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref; $dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref; - - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) @@ -3512,7 +3516,7 @@ class Propal extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal")); return ""; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 241f22cfe38..4377ebe6211 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -272,7 +272,7 @@ $sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.to $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; $sql.= ' u.login'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user,"; +if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 29688b7d690..0f875b68f22 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2591,7 +2591,7 @@ if ($action == 'create' && $user->rights->commande->creer) } } else { $langs->load("errors"); - print ''; + print ''; } } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f1f9dbd1b00..b1e2262f109 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -321,6 +321,7 @@ class Commande extends CommonOrder public function valid($user, $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; @@ -423,13 +424,18 @@ class Commande extends CommonOrder // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) - // in order not to lose the attachments + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->commande->dir_output.'/'.$oldref; $dirdest = $conf->commande->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 61acf6e3a89..378d6087cc7 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ if ($action=="create" || $action=="start") } // Get the bank account dedicated to this point of sale module/terminal - $vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse; + $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 5ba7232dc95..38a5f88842a 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -190,7 +190,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $socialcontrib->getNomUrl(1, '20'); print ''; // Type - print ''.$obj->lib.''; + print ''.$obj->lib.''; // Expected to pay print ''.price($obj->total).''; // Ref payment diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2f017b485d6..bfa21a9c759 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -309,6 +309,38 @@ if (empty($reshook)) dol_print_error($db, $object->error); } + elseif ($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); + } + + elseif ($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); + } + + elseif ($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 elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -1209,6 +1241,16 @@ if (empty($reshook)) $object->situation_counter = 1; $object->situation_final = 0; $object->situation_cycle_ref = $object->newCycle(); + + + $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(); @@ -3147,6 +3189,44 @@ if ($action == 'create') $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); 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 '' . $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', -1, 1); + print ''; + + print ''; + } + } + // Payment mode print '' . $langs->trans('PaymentMode') . ''; $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); @@ -4020,6 +4100,126 @@ elseif ($id > 0 || ! empty($ref)) print ''; } + $displayWarranty = false; + 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->situation_final) && !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 ''; + 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 ''; + + // Retained warranty payment term + print ''; + print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer){ + print ''; + } + + print '
'; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); + print 'id . '">' . img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 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 == 'editretainedwarrantypaymentterms') + { + //date('Y-m-d',$object->date_lim_reglement) + 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', -1, 1); + print ''; + print '
'; + } + else + { + 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" '); + } + } + print ''; + + + + + if($displayWarranty) + { + // Retained Warranty payment date limit + 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 ''; + } + } + + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -4464,6 +4664,31 @@ elseif ($id > 0 || ! empty($ref)) print ' :'; print '' . price($resteapayeraffiche) . ''; print ' '; + + // Retained warranty : usualy use on construction industry + if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){ + + // Billed - retained warranty + if($object->type == Facture::TYPE_SITUATION) + { + $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; + } + else + { + // Because one day retained warranty could be used on standard invoices + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + } + + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; + + print '' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')) . ' :' . price($billedWithRetainedWarranty) . ' '; + + // retained warranty + print ''; + 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, 'day')):''; + print ' :' . price($retainedWarranty) . ' '; + } } else // Credit note { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e54e11896b5..c64c42e2971 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -206,6 +206,21 @@ class Facture extends CommonInvoice public $oldcopy; + /** + * @var double percentage of retainage + */ + public $retained_warranty; + + /** + * @var int timestamp of date limit of retainage + */ + public $retained_warranty_date_limit; + + /** + * @var int Code in llx_c_paiement + */ + public $retained_warranty_fk_cond_reglement; + /** * Standard invoice */ @@ -472,6 +487,9 @@ class Facture extends CommonInvoice $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; + $sql.= ", retained_warranty"; + $sql.= ", retained_warranty_date_limit"; + $sql.= ", retained_warranty_fk_cond_reglement"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -506,6 +524,10 @@ class Facture extends CommonInvoice $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)); + $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); @@ -1336,6 +1358,7 @@ class Facture extends CommonInvoice $sql.= ', f.fk_incoterms, f.location_incoterms'; $sql.= ', f.module_source, f.pos_source'; $sql.= ", i.libelle as label_incoterms"; + $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'; @@ -1405,6 +1428,10 @@ class Facture extends CommonInvoice $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; $this->situation_final = $obj->situation_final; + $this->retained_warranty = $obj->retained_warranty; + $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); + $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; + $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms @@ -1648,6 +1675,8 @@ class Facture extends CommonInvoice if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); + // Check parameters // Put here code to add control on parameters values @@ -1688,7 +1717,10 @@ class Facture extends CommonInvoice $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; $sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).","; $sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).","; - $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)); + $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)).","; + $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_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(); @@ -2429,13 +2461,18 @@ class Facture extends CommonInvoice // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of object directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->facture->dir_output.'/'.$oldref; $dirdest = $conf->facture->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -3458,7 +3495,7 @@ class Facture extends CommonInvoice else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); return ""; } } @@ -4369,6 +4406,137 @@ class Facture extends CommonInvoice return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); } + + + /** + * @return number or -1 if not available + */ + public function getRetainedWarrantyAmount() + { + if(empty($this->retained_warranty) ){ + return -1; + } + + $retainedWarrantyAmount = 0; + + // Billed - retained warranty + if($this->type == Facture::TYPE_SITUATION) + { + $displayWarranty = true; + // Check if this situation invoice is 100% for real + if(!empty($this->lines)){ + foreach($this->lines as $i => $line){ + if($line->product_type < 2 && $line->situation_percent < 100){ + $displayWarranty = false; + break; + } + } + } + + if($displayWarranty && !empty($this->situation_final)) + { + $this->fetchPreviousNextSituationInvoice(); + $TPreviousIncoice = $this->tab_previous_situation_invoice; + + $total2BillWT = 0; + foreach ($TPreviousIncoice as &$fac){ + $total2BillWT += $fac->total_ttc; + } + $total2BillWT += $this->total_ttc; + + $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; + } + else{ + return -1; + } + } + else + { + // Because one day retained warranty could be used on standard invoices + $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; + } + + return $retainedWarrantyAmount; + } + + /** + * Change the retained warranty + * + * @param float $value value of retained warranty + * @return int >0 if OK, <0 if KO + */ + public 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 int $timestamp date limit of retained warranty in timestamp format + * @param string $dateYmd date limit of retained warranty in Y m d format + * @return int >0 if OK, <0 if KO + */ + public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) + { + if(!$timestamp && $dateYmd){ + $timestamp = $this->db->jdate($dateYmd); + } + + + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); + 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/compta/facture/list.php b/htdocs/compta/facture/list.php index 2982246c6d9..eca39ade98c 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -182,6 +182,12 @@ $arrayfields=array( 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); + +if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) +{ + $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0); +} + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -373,6 +379,10 @@ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; $sql.= ' f.datec as date_creation, f.tms as date_update,'; +if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) +{ + $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,'; +} $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; @@ -834,6 +844,13 @@ if ($resql) print ''; print ''; } + + if(! empty($arrayfields['f.retained_warranty']['checked'])) + { + print ''; + print ''; + } + if (! empty($arrayfields['dynamount_payed']['checked'])) { print ''; @@ -899,6 +916,7 @@ if ($resql) if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields @@ -939,7 +957,15 @@ if ($resql) $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); $facturestatic->note_public=$obj->note_public; $facturestatic->note_private=$obj->note_private; - + if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) + { + $facturestatic->retained_warranty=$obj->retained_warranty; + $facturestatic->retained_warranty_date_limit=$obj->retained_warranty_date_limit; + $facturestatic->situation_final=$obj->retained_warranty_date_limit; + $facturestatic->situation_final=$obj->retained_warranty_date_limit; + $facturestatic->situation_cycle_ref=$obj->situation_cycle_ref; + $facturestatic->situation_counter=$obj->situation_counter; + } $thirdpartystatic->id=$obj->socid; $thirdpartystatic->name=$obj->name; $thirdpartystatic->client=$obj->client; @@ -1181,6 +1207,11 @@ if ($resql) $totalarray['totalttc'] += $obj->total_ttc; } + if(! empty($arrayfields['f.retained_warranty']['checked'])) + { + print ''.(! empty($obj->retained_warranty)?price($obj->retained_warranty).'%':' ').''; + } + if (! empty($arrayfields['dynamount_payed']['checked'])) { print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').''; // TODO Use a denormalized field diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index d9a912ea50b..26e3f2792d6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -489,7 +489,7 @@ class RemiseCheque extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank")); return ""; } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index a3c79d23602..614782c519b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1141,7 +1141,7 @@ class Paiement extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); return ""; } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1a98c33ab02..a60330270d4 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1417,7 +1417,7 @@ class BonPrelevement extends CommonObject $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; $sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; - $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum"; + $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum"; $sql.= " FROM"; $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql.= " ".MAIN_DB_PREFIX."facture as f,"; @@ -1443,7 +1443,8 @@ class BonPrelevement extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum, $obj->rum); + $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum); $this->total = $this->total + $obj->somme; $i++; } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 2dfbb5adf9d..eaef92a1abc 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -78,7 +78,7 @@ if (empty($reshook)) // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $bprev = new BonPrelevement($db); $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); - + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate); if ($result < 0) { @@ -116,7 +116,7 @@ llxHeader('', $langs->trans("NewStandingOrder")); if (prelevement_check_config() < 0) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); } /*$h=0; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 4e2c4e2d3a5..1be716f8f61 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -58,7 +58,7 @@ llxHeader('', $langs->trans("CustomersStandingOrdersArea")); if (prelevement_check_config() < 0) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors'); } print load_fiche_titre($langs->trans("CustomersStandingOrdersArea")); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 7e25d8c3423..5f7f7d0fc0a 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -187,7 +187,7 @@ if ($resql) if ($year) { - $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":""); + $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":""); print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); } else @@ -281,7 +281,7 @@ if ($resql) print ''; if ($obj->periode) { - print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; + print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; } else { diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 9bf94a16b34..af215902d0e 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -90,7 +90,7 @@ print ''; if ($mode != 'sconly') { - $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } else @@ -181,7 +181,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $socialcontrib->getNomUrl(1, '20'); print ''; // Type - print ''.$obj->lib.''; + print ''.$obj->lib.''; // Date $date=$obj->periode; if (empty($date)) $date=$obj->date_ech; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 3f0d0313ee0..9cde6e2df4e 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -38,7 +38,7 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); if ($id > 0) $object->fetch($id); -if(empty($object->thirdparty)) $object->fetch_thirdparty(); +if (empty($object->thirdparty)) $object->fetch_thirdparty(); $socid = $object->thirdparty->id; // Sort & Order fields @@ -69,7 +69,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); -$type_element = GETPOST('type_element')?GETPOST('type_element'):''; +$type_element = GETPOSTISSET('type_element')?GETPOST('type_element'):''; // Load translation files required by the page $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); @@ -173,13 +173,13 @@ if ($type_element == 'fichinter') $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, '; $tables_from = MAIN_DB_PREFIX.'fichinterdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number='f.ref'; } -if ($type_element == 'invoice') +elseif ($type_element == 'invoice') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $documentstatic=new Facture($db); @@ -187,14 +187,14 @@ if ($type_element == 'invoice') $tables_from = MAIN_DB_PREFIX.'facturedet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $where = " WHERE f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; $doc_number='f.ref'; $thirdTypeSelect='customer'; } -if ($type_element == 'propal') +elseif ($type_element == 'propal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $documentstatic=new Propal($db); @@ -202,14 +202,14 @@ if ($type_element == 'propal') $tables_from = MAIN_DB_PREFIX.'propaldet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('propal').')'; $datePrint = 'c.datep'; $doc_number='c.ref'; $thirdTypeSelect='customer'; } -if ($type_element == 'order') +elseif ($type_element == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $documentstatic=new Commande($db); @@ -217,14 +217,14 @@ if ($type_element == 'order') $tables_from = MAIN_DB_PREFIX.'commandedet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('order').')'; $dateprint = 'c.date_commande'; $doc_number='c.ref'; $thirdTypeSelect='customer'; } -if ($type_element == 'supplier_invoice') +elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $documentstatic=new FactureFournisseur($db); @@ -232,14 +232,14 @@ if ($type_element == 'supplier_invoice') $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'f.datef'; $doc_number='f.ref'; $thirdTypeSelect='supplier'; } -//if ($type_element == 'supplier_proposal') +//elseif ($type_element == 'supplier_proposal') //{ // require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // $documentstatic=new SupplierProposal($db); @@ -252,7 +252,7 @@ if ($type_element == 'supplier_invoice') // $doc_number='c.ref'; // $thirdTypeSelect='supplier'; //} -if ($type_element == 'supplier_order') +elseif ($type_element == 'supplier_order') { // Supplier : Show products from orders. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $documentstatic=new CommandeFournisseur($db); @@ -260,14 +260,14 @@ if ($type_element == 'supplier_order') $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'c.date_valid'; $doc_number='c.ref'; $thirdTypeSelect='supplier'; } -if ($type_element == 'contract') +elseif ($type_element == 'contract') { // Order require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $documentstatic=new Contrat($db); @@ -276,7 +276,7 @@ if ($type_element == 'contract') $tables_from = MAIN_DB_PREFIX.'contratdet d'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; $tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid'; + $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $dateprint = 'c.date_valid'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e7461e2a053..e6e9b7f2e4d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -245,7 +245,7 @@ class Contrat extends CommonObject else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract")); return ""; } } @@ -486,13 +486,18 @@ class Contrat extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of object directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->contract->dir_output.'/'.$oldref; $dirdest = $conf->contract->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 7ef25e62b8b..e039529eef7 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -17,7 +17,7 @@ /** * \file /htdocs/core/ajax/extraparams.php - * \brief File to return Ajax response on set extra parameters of elements + * \brief File to make Ajax action on setting extra parameters of elements */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 6b06cccd50c..987a59ec3fb 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -15,8 +15,9 @@ */ /** - * \file htdocs/core/ajax/productonoff.php - * \brief File to set tosell and tobuy for product + * \file htdocs/core/ajax/objectonoff.php + * \brief File to set status for an object + * This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal @@ -36,6 +37,13 @@ $field=GETPOST('field', 'alpha'); $element=GETPOST('element', 'alpha'); $object = new GenericObject($db); + +// Security check +if (! empty($user->societe_id)) + $socid = $user->societe_id; + + + /* * View */ @@ -44,6 +52,20 @@ top_httphead(); print ''."\n"; +if ($element == 'societe' && in_array($field, array('status'))) +{ + $result = restrictedArea($user, 'societe', $id); +} +elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) +{ + $result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid'); +} +else +{ + accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1); + exit; +} + // Registering new values if (($action == 'set') && ! empty($id)) $object->setValueFrom($field, $value, $element, $id); diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php new file mode 100644 index 00000000000..9b46546f5c3 --- /dev/null +++ b/htdocs/core/ajax/pingresult.php @@ -0,0 +1,72 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/pingresult.php + * \brief File to save result of anonymous ping + * Example: captureserver/public/index.php?action=dolibarrping + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$action=GETPOST('action', 'alpha'); +$hash_unique_id=GETPOST('hash_unique_id', 'alpha'); +$hash_algo=GETPOST('hash', 'alpha'); + + +// Security check +if (! empty($user->societe_id)) + $socid = $user->societe_id; + +$now = dol_now(); + + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +// If ok +if ($action == 'firstpingok') +{ + // Note: pings are by entities + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt')); + dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id); + + print 'First ping OK saved for entity '.$conf->entity; +} +// If ko +elseif ($action == 'firstpingko') +{ + // Note: pings are by entities + dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); + print 'First ping KO saved for entity '.$conf->entity; +} +else { + print 'Error action='.$action.' not supported'; +} diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 9e7dea2ef95..faaddd31b23 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -17,7 +17,7 @@ /** * \file htdocs/core/ajax/security.php - * \brief This ajax component is used to generated has keys for security purposes + * \brief This ajax component is used to generated hash keys for security purposes * like key to use into URL to protect them. */ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 67c3f0f9630..f69b4db68c1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2053,6 +2053,43 @@ abstract class CommonObject return -2; } } + + /** + * Change the retained warranty payments terms + * + * @param int $id Id of new payment terms + * @return int >0 if OK, <0 if KO + */ + public 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 @@ -6047,6 +6084,12 @@ abstract class CommonObject $type='link'; $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); } + elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N'); + $type = 'sellist'; + } + + $langfile=$val['langfile']; $list=$val['list']; $help=$val['help']; diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index af87e25fad1..57a076963fd 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -63,11 +63,20 @@ class Events // extends CommonObject public $dateevent; + public $ip; + + public $user_agent; + /** * @var string description */ public $description; + /** + * @var string Prefix session obtained with method dol_getprefix() + */ + public $prefix_session; + // List of all Audit/Security events supported by triggers public $eventstolog=array( array('id'=>'USER_LOGIN', 'test'=>1), @@ -108,6 +117,18 @@ class Events // extends CommonObject ); + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), + ); + + /** * Constructor * @@ -144,7 +165,8 @@ class Events // extends CommonObject $sql.= "user_agent,"; $sql.= "dateevent,"; $sql.= "fk_user,"; - $sql.= "description"; + $sql.= "description,"; + $sql.= "prefix_session"; $sql.= ") VALUES ("; $sql.= " '".$this->db->escape($this->type)."',"; $sql.= " ".$conf->entity.","; @@ -152,7 +174,8 @@ class Events // extends CommonObject $sql.= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; $sql.= " '".$this->db->idate($this->dateevent)."',"; $sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').","; - $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."'"; + $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; + $sql.= " '".$this->db->escape(dol_getprefix())."'"; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -222,7 +245,8 @@ class Events // extends CommonObject $sql.= " t.dateevent,"; $sql.= " t.description,"; $sql.= " t.ip,"; - $sql.= " t.user_agent"; + $sql.= " t.user_agent,"; + $sql.= " t.prefix_session"; $sql.= " FROM ".MAIN_DB_PREFIX."events as t"; $sql.= " WHERE t.rowid = ".$id; @@ -242,6 +266,7 @@ class Events // extends CommonObject $this->description = $obj->description; $this->ip = $obj->ip; $this->user_agent = $obj->user_agent; + $this->prefix_session = $obj->prefix_session; } $this->db->free($resql); @@ -293,5 +318,8 @@ class Events // extends CommonObject $this->type=''; $this->dateevent=time(); $this->description='This is a specimen event'; + $this->ip = '1.2.3.4'; + $this->user_agent = 'Mozilla specimen User Agent X.Y'; + $this->prefix_session = dol_getprefix(); } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0e6b0befef9..09130bb130a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1411,7 +1411,7 @@ class ExtraFields // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); - } elseif (preg_match("#^.*list.php$#", $_SERVER["DOCUMENT_URI"])) { + } elseif (preg_match("#^.*list.php$#", $_SERVER["PHP_SELF"])) { // Pattern for word=$ID$ $word = '\b[a-zA-Z0-9-\.-_]+\b=\$ID\$'; @@ -1445,13 +1445,13 @@ class ExtraFields $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); } else { if (!empty($matchCondition[1])) { - $boolCond = (($matchCondition[1] == "AND") ? ' AND 1 ' : ' OR 0 '); + $boolCond = (($matchCondition[1] == "AND") ? ' AND TRUE ' : ' OR FALSE '); $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond . $matchCondition[3], $InfoFieldList[4]); } elseif (!empty($matchCondition[3])) { - $boolCond = (($matchCondition[3] == "AND") ? ' 1 AND ' : ' 0 OR'); + $boolCond = (($matchCondition[3] == "AND") ? ' TRUE AND ' : ' FALSE OR'); $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]); } else { - $InfoFieldList[4] = 1; + $InfoFieldList[4] = " TRUE "; } } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index ee090fed65d..2f0ae34b529 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/ajax/fileupload.php + * \file htdocs/core/ajax/fileupload.class.php * \brief File to return Ajax response on file upload */ diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index f9b0a59280f..ea038fa8131 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -199,8 +199,6 @@ class FormMargin if (! $user->rights->margins->liretous) return; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - $marginInfo = $this->getMarginInfosArray($object, $force_price); if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better @@ -240,13 +238,13 @@ class FormMargin //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print ''; print ''.$langs->trans('MarginOnProducts').''; - print ''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_products']).''; + print ''.price($marginInfo['pa_products']).''; + print ''.price($marginInfo['margin_on_products']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').''; print ''; } @@ -254,13 +252,13 @@ class FormMargin { print ''; print ''.$langs->trans('MarginOnServices').''; - print ''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_services']).''; + print ''.price($marginInfo['pa_services']).''; + print ''.price($marginInfo['margin_on_services']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').''; print ''; } @@ -268,13 +266,13 @@ class FormMargin { print ''; print ''.$langs->trans('TotalMargin').''; - print ''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_total']).''; + print ''.price($marginInfo['pa_total']).''; + print ''.price($marginInfo['total_margin']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; print ''; } print ''; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 14c69259b98..79ad6d19115 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -148,6 +148,7 @@ print ' /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { var page_y = $(document).scrollTop(); + if (page_y > 0) { if (this.href) @@ -157,7 +158,7 @@ print ' } else { - console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y); + console.log("We click on tag with .reposition class but element is not an html tag, so we try to update input form field page_y with value "+page_y); jQuery("input[type=hidden][name=page_y]").val(page_y); } } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index a96e63a4f43..43f4723d695 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -538,11 +538,12 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof } /** - * On/off button for object + * On/off button to change status of an object + * This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php * * @param Object $object Object to set * @param string $code Name of constant : status or status_buy for product by example - * @param string $field Name of database field : tosell or tobuy for product by example + * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example * @param string $text_on Text if on * @param string $text_off Text if off * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9aa6177adf4..e34c3e3b7b5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2447,6 +2447,13 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } } + elseif (strtoupper($countrycode) == "JM") + {//Jamaïque + if(dol_strlen($newphone) == 12) + {//ex: +1867_ABC_DEFG + $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); + } + } elseif (strtoupper($countrycode) == "MG") {//Madagascar if(dol_strlen($phone) == 13) @@ -4400,7 +4407,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ { if ($currency_code == 'auto') $currency_code=$conf->currency; - $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY'); + $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD'); $listoflanguagesbefore=array('nl_NL'); if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) { @@ -6554,10 +6561,17 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o $newmesgarray=array(); foreach($mesgarray as $val) { - $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); - $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); - $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); - $newmesgarray[]=$tmpmesgstring; + if (is_string($val)) + { + $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); + $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); + $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); + $newmesgarray[]=$tmpmesgstring; + } + else + { + dol_syslog("Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING); + } } $mesgarray=$newmesgarray; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 9495a13edde..b3d518eb088 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/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c1b5f4c489d..ba42ebd23d8 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2212,3 +2212,49 @@ function pdf_getSizeForImage($realpath) } return array('width'=>$width,'height'=>$height); } + +/** + * Return line total amount discount + * + * @param Object $object Object + * @param int $i Current line number + * @param Translate $outputlangs Object langs for output + * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) + * @return string Return total of line excl tax + */ +function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0) +{ + global $conf, $hookmanager; + $sign=1; + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + if ($object->lines[$i]->special_code == 3) + { + return $outputlangs->transnoentities("Option"); + } + else + { + + if (is_object($hookmanager)) + { + $special_code = $object->lines[$i]->special_code; + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + + $parameters = array( + 'i'=>$i, + 'outputlangs'=>$outputlangs, + 'hidedetails'=>$hidedetails, + 'special_code'=>$special_code + ); + + $action=''; + + if( $hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action)>0) + { + return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks + } + } + + if (empty($hidedetails) || $hidedetails > 1) return $sign * ( ($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht ); + } + return ''; +} diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 051f3a5392a..2ee5a45c010 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -279,7 +279,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f // Check write permission from module (we need to know write permission to create but also to delete drafts record) $createok=1; $nbko=0; - if (GETPOST('action', 'aZ09') == 'create' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) + if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) { foreach ($featuresarray as $feature) { @@ -329,7 +329,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f // If a or and at least one ok if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; - if (GETPOST('action', 'aZ09') == 'create' && ! $createok) accessforbidden(); + if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden(); //print "Write access is ok"; } diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index d5e2d3be854..07573db1a11 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -38,7 +38,8 @@ function takepos_prepare_head() $head[$h][2] = 'setup'; $h++; - for ($i = 1; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for ($i = 1; $i <= $numterminals; $i++) { $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i; $head[$h][1] = $langs->trans("Terminal"). " ".$i; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index a4c187f2ffa..00716f6a3ab 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -339,6 +339,14 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri } } + if (defined('USEDOLIBARREDITOR')) + { + print '
'; + print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. There is no preview for this page."; + print '
'; + exit; + } + if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server { // Check new container exists diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 80876747d59..f2ef19ca19a 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -252,7 +252,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(32, 26); - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); + $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(10, 32); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 53929f28e75..acc88a1e96a 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1347,6 +1347,50 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); + + // Retained warranty + if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) ) + { + $displayWarranty = false; + + // 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/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b5529c78d8e..26e2b1824d8 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1225,13 +1225,172 @@ class pdf_sponge extends ModelePDFFactures $useborder=0; $index = 0; + + + // pourcentage global d'avancement + $percent = 0; + $i=0; + foreach ($object->lines as $line) + { + if(!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)){ + $percent += $line->situation_percent; + $i++; + } + } + if(!empty($i)){ + $avancementGlobal = $percent/$i; + } + else{ + $avancementGlobal = 0; + } + + $object->fetchPreviousNextSituationInvoice(); + $TPreviousIncoice = $object->tab_previous_situation_invoice; + + $total_a_payer = 0; + $total_a_payer_ttc = 0; + foreach ($TPreviousIncoice as &$fac){ + $total_a_payer += $fac->total_ht; + $total_a_payer_ttc += $fac->total_ttc; + } + $total_a_payer += $object->total_ht; + $total_a_payer_ttc += $object->total_ttc; + + if(!empty($avancementGlobal)){ + $total_a_payer = $total_a_payer * 100 / $avancementGlobal; + $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal; + } + else{ + $total_a_payer = 0; + $total_a_payer_ttc = 0; + } + + $deja_paye = 0; + $i = 1; + if(!empty($TPreviousIncoice)){ + + $pdf->setY($tab2_top); + $posy = $pdf->GetY(); + + + + + foreach ($TPreviousIncoice as &$fac){ + + if($posy > $this->page_hauteur - 4 ) { + $this->_pagefoot($pdf, $object, $outputlangs, 1); + $pdf->addPage(); + $pdf->setY($this->marge_haute); + $posy = $pdf->GetY(); + } + + // cumul TVA précédent + $index++; + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $posy); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $pdf->SetXY($col2x, $posy); + + $facSign = ''; + if($i>1){ + $facSign = $fac->total_ht>=0?'+':''; + } + + $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs); + + $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1); + + $i++; + $deja_paye += $fac->total_ht; + $posy += $tab2_hl; + + $pdf->setY($posy); + } + + // Display curent total + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $posy); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $pdf->SetXY($col2x, $posy); + $facSign = ''; + if($i>1){ + $facSign = $object->total_ht>=0?'+':''; // gestion d'un cas particulier client + } + + if($fac->type === facture::TYPE_CREDIT_NOTE){ + $facSign = '-'; // les avoirs + } + + + $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs); + $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1); + + $posy += $tab2_hl; + + // Display all total + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $posy); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1); + + $pdf->SetXY($col2x, $posy); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer*$avancementGlobal/100, 0, $outputlangs), 0, 'R', 1); + $pdf->SetFont('', '', $default_font_size - 2); + + $posy += $tab2_hl; + + if($posy > $this->page_hauteur - 4 ) { + $pdf->addPage(); + $pdf->setY($this->marge_haute); + $posy = $pdf->GetY(); + } + + $tab2_top = $posy; + $index=0; + } + + $tab2_top += 3; + + // Get Total HT + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); + + // Total remise + $total_line_remise=0; + foreach($object->lines as $i => $line) { + $total_line_remise+= pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib + // Gestion remise sous forme de ligne négative + if($line->total_ht < 0) $total_line_remise += -$line->total_ht; + } + if($total_line_remise > 0) { + if (! empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) { + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount"), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1); + + $index++; + } + // Show total NET before discount + if (! empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) { + $pdf->SetFillColor(255, 255, 255); + $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount"), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1); + + $index++; + } + } + // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); - $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1256,7 +1415,7 @@ class pdf_sponge extends ModelePDFFactures //{ foreach($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; foreach($localtax_rate as $tvakey => $tvaval) { @@ -1330,7 +1489,14 @@ class pdf_sponge extends ModelePDFFactures } if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) - $coef_fix_tva = $object->total_tva / $sum_pdf_tva; + if(!empty($sum_pdf_tva)) + { + $coef_fix_tva = $object->total_tva / $sum_pdf_tva; + } + else { + $coef_fix_tva = 1; + } + foreach($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey]=$tvaval * $coef_fix_tva; @@ -1427,7 +1593,7 @@ class pdf_sponge extends ModelePDFFactures } } } - //} + // Revenue stamp if (price2num($object->revenuestamp) != 0) @@ -1449,6 +1615,69 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); + + + /*if($object->type == Facture::TYPE_SITUATION) + { + // reste à payer total + $index++; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetFillColor(255,255,255); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('SituationTotalRayToRest'), 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer_ttc-$deja_paye, 0, $outputlangs), 0, 'R', 1); + }*/ + + + // Retained warranty + if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) ) + { + $displayWarranty = false; + + // Check if this situation invoice is 100% for real + if(!empty($object->situation_final)){ + $displayWarranty = true; + } + elseif(!empty($object->lines) && $object->status == Facture::STATUS_DRAFT ){ + // $object->situation_final need validation to be done so this test is need for draft + $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 = $total_a_payer_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("PDFEVOLToPayOn", 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("PDFEVOLRetainedWarranty") . ' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", 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); + } + } } } @@ -1456,7 +1685,7 @@ class pdf_sponge extends ModelePDFFactures $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); - //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if ($object->paye) $resteapayer=0; @@ -1509,6 +1738,20 @@ class pdf_sponge extends ModelePDFFactures return ($tab2_top + ($tab2_hl * $index)); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { + // phpcs:enable + return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub + } + /** * Show table for lines * diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index fa32d3df0d2..936eabeadda 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -136,12 +136,12 @@ class pdf_soleil extends ModelePDFFicheinter $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_logo = 1; // Display logo + $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 0; // Display payment mode + $this->option_condreg = 0; // Display payment terms + $this->option_codeproduitservice = 0; // Display product-service code + $this->option_multilang = 1; // Available in several languages $this->option_draft_watermark = 1; //Support add of a watermark on drafts // Get source company diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 1311264f7fb..0a60d9dc0ae 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -594,16 +594,25 @@ class ImportCsv extends ModeleImports // Test regexp 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 test is "Must exist in a field@table or field@table:..." + if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { $field=$reg[1]; $table=$reg[2]; + $filter=!empty($reg[3])?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) { @@ -612,7 +621,7 @@ class ImportCsv extends ModeleImports while ($i < $num) { $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; + if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; $i++; } } @@ -623,9 +632,11 @@ class ImportCsv extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval, $this->cachefieldtable[$field.'@'.$table])) + if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) { - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table); + $tableforerror = $table; + if(! empty($filter)) $tableforerror.= ':'.$filter; + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 00db9096bca..af9c0e2c412 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -621,16 +621,25 @@ class ImportXlsx extends ModeleImports // Test regexp 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 test is "Must exist in a field@table or field@table:..." + if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { $field=$reg[1]; $table=$reg[2]; + $filter=!empty($reg[3])?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) { @@ -639,7 +648,7 @@ class ImportXlsx extends ModeleImports while ($i < $num) { $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield; + if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; $i++; } } @@ -650,9 +659,11 @@ class ImportXlsx extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval, $this->cachefieldtable[$field.'@'.$table])) + if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) { - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table); + $tableforerror = $table; + if(! empty($filter)) $tableforerror.= ':'.$filter; + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 0a339a9a61f..fcb5ef8433e 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -139,9 +139,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_logo = 1; // Display logo FAC_PDF_LOGO + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Display product-service code $this->franchise=!$mysoc->tva_assuj; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 092d5ac10b7..4b819a5bcae 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -425,8 +425,8 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product'); - $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*" - ); + $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"); + $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0'); $this->import_convertvalue_array[$r]=array( 'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), @@ -444,7 +444,10 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' ); $this->import_convertvalue_array[$r]=array( @@ -463,7 +466,10 @@ class modCategorie extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0' ); $this->import_convertvalue_array[$r]=array( diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 1d7e3d983fb..381d68c16d2 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -438,7 +438,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); } $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); if (is_array($elementarray) && count($elementarray) > 0) { diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index d185b4cfcf7..4a873847d8a 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -393,7 +393,7 @@ abstract class ModeleAccountancyCode * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int <0 if KO, >0 if OK - * @deprecated Use the new function generateDocument of Facture class + * @deprecated Use the new function generateDocument of Objects class * @see Societe::generateDocument() */ function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index bf46ecb9890..75c6f72e1df 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -255,6 +255,25 @@ if ($nolinesbefore) { { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } + + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + { + ?> + + select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - ?> - - global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> + + '; echo ''; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 2c5c27bc939..5fd43a69a37 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -114,8 +114,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['propal'] as $element) { $ret=$element->classifyBilled($user); @@ -143,7 +143,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -166,7 +166,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['propal'] as $element) { @@ -195,8 +195,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['order_supplier'] as $element) { $ret=$element->classifyBilled($user); @@ -218,7 +218,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['supplier_proposal'] as $element) { @@ -246,7 +246,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -345,4 +345,24 @@ class InterfaceWorkflowManager extends DolibarrTriggers return 0; } + + /** + * @param Object $conf Dolibarr settings object + * @param float $totalonlinkedelements Sum of total amounts (excl VAT) of + * invoices linked to $object + * @param float $object_total_ht The total amount (excl VAT) of the object + * (an order, a proposal, a bill, etc.) + * @return bool True if the amounts are equal (rounded on total amount) + * True if the module is configured to skip the amount equality check + * False otherwise. + */ + private function shouldClassify($conf, $totalonlinkedelements, $object_total_ht) + { + // if the configuration allows unmatching amounts, allow classification anyway + if (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) { + return true; + } + // if the amount are same, allow classification, else deny + return (price2num($totalonlinkedelements, 'MT') == price2num($object_total_ht, 'MT')); + } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bdd07c4e38d..07499ac8893 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -649,12 +649,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc; @@ -664,12 +672,20 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda","other","members")); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); - $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; - $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; - $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day'); + $member = $this->context['member']; + if (! is_object($member)) // This should not happen + { + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($this->fk_adherent); + } + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->id, $member->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->fk_type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); $object->sendtoid=0; if ($object->fk_soc > 0) $object->socid=$object->fk_soc; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index bdbed6b2027..cc05bf686c3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1584,9 +1584,9 @@ if ($action == 'create') print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); print ''; } - - $indiceAsked++; } + + $indiceAsked++; } print ""; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b0bb148c1e2..97c67fd7701 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -813,13 +813,18 @@ class Expedition extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) - // in order not to lose the attached files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->expedition->dir_output.'/sending/'.$oldref; $dirdest = $conf->expedition->dir_output.'/sending/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 04044e0ad97..a764e2df47c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1958,7 +1958,7 @@ else if ($resql) { $num = $db->num_rows($resql); - $i = 0; $total = 0; + $i = 0; $totalpaid = 0; while ($i < $num) { $objp = $db->fetch_object($resql); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index da14554f40f..34f60120925 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1151,13 +1151,18 @@ class ExpenseReport extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) - // in order not to lose the attachments + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->expensereport->dir_output.'/'.$oldref; $dirdest = $conf->expensereport->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d9e01a6579f..6ff7fac5d08 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -574,13 +574,20 @@ class Fichinter extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of object directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files + 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->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(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->ficheinter->dir_output.'/'.$oldref; $dirdest = $conf->ficheinter->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index bbaa5279373..9d5bfce0189 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -551,13 +551,18 @@ class CommandeFournisseur extends CommonOrder // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // We rename directory ($this->ref = ancienne ref, $num = nouvelle ref) - // in order not to lose the attached files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->fournisseur->commande->dir_output.'/'.$oldref; $dirdest = $conf->fournisseur->commande->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 6bedfcb5c1f..41ac2f126a7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1320,6 +1320,7 @@ class FactureFournisseur extends CommonInvoice public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $now=dol_now(); @@ -1416,14 +1417,18 @@ class FactureFournisseur extends CommonInvoice // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref) - // in order not to lose the attached files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$oldref; $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e4d70ff255a..51485a7db5e 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -701,7 +701,7 @@ class PaiementFourn extends Paiement else { $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Supplier")); return ""; } } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 48599a5bbf2..df29d329e0d 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017 Ferran Marcet @@ -239,6 +239,16 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2]; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + if (! empty($dto)) { + $unit_price = price2num(GETPOST("pu_" . $reg[1]) * (100 - $dto) / 100, 'MU'); + } + $saveprice = "saveprice_" . $reg[1] . '_' . $reg[2]; + } + } + // We ask to move a qty if (GETPOST($qty) != 0) { if (! (GETPOST($ent, 'int') > 0)) { @@ -254,6 +264,24 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) setEventMessages($object->error, $object->errors, 'errors'); $error ++; } + + if (! $error && ! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + //update supplier price + if (isset($_POST[$saveprice])) { + // TODO Use class + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price"; + $sql .= " SET unitprice='" . GETPOST($pu) . "'"; + $sql .= ", price=" . GETPOST($pu) . "*quantity"; + $sql .= ", remise_percent='" . $dto . "'"; + $sql .= " WHERE fk_soc=" . $object->socid; + $sql .= " AND fk_product=" . GETPOST($prod, 'int'); + + $resql = $db->query($sql); + } + } + } } } } @@ -552,6 +580,15 @@ if ($id > 0 || ! empty($ref)) { print '' . $langs->trans("QtyDispatchedShort") . ''; print '' . $langs->trans("QtyToDispatchShort") . ''; print ''; + + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + print '' . $langs->trans("Price") . ''; + print '' . $langs->trans("ReductionShort") . ' (%)'; + print '' . $langs->trans("UpdatePrice") . ''; + } + } + print '' . $langs->trans("Warehouse") . ''; // Enable hooks to append additional columns @@ -760,6 +797,25 @@ if ($id > 0 || ! empty($ref)) { print ''; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + // Price + print ''; + print ''; + print ''; + + // Discount + print ''; + print ''; + print ''; + + // Save price + print ''; + print ''; + print ''; + } + } + // Warehouse print ''; if (count($listwarehouses) > 1) { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 533f6c9c748..0245073a060 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1438,45 +1438,30 @@ class Holiday extends CommonObject $result = $this->db->query($sql); $typeleaves=$this->getTypes(1, 1); - foreach($typeleaves as $key => $val) - { - // On ajoute x jours à chaque utilisateurs - $nb_holiday = $val['newByMonth']; - if (empty($nb_holiday)) $nb_holiday=0; - if ($nb_holiday > 0) + // Update each user counter + foreach ($users as $userCounter) { + $nbDaysToAdd = $typeleaves[$userCounter['type']]['newByMonth']; + if(empty($nbDaysToAdd)) continue; + + dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); + + $nowHoliday = $userCounter['nb_holiday']; + $newSolde = $nowHoliday + $nbDaysToAdd; + + // We add a log for each user + $this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); + + $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); + + if ($result < 0) { - dol_syslog("We update leavefor everybody for type ".$key, LOG_DEBUG); - - $i = 0; - while ($i < $nbUser) - { - $now_holiday = $this->getCPforUser($users[$i]['rowid'], $val['rowid']); - $new_solde = $now_holiday + $nb_holiday; - - // We add a log for each user - $this->addLogCP($user->id, $users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $new_solde, $val['rowid']); - - $i++; - } - - // Now we update counter for all users at once - $sql2 = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql2.= " nb_holiday = nb_holiday + ".$nb_holiday; - $sql2.= " WHERE fk_type = ".$val['rowid']; - - $result= $this->db->query($sql2); - - if (! $result) - { - dol_print_error($this->db); - break; - } + $error++; + break; } - else dol_syslog("No change for leave of type ".$key, LOG_DEBUG); } - if ($result) + if (! $error) { $this->db->commit(); return 1; @@ -1635,10 +1620,10 @@ class Holiday extends CommonObject { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = '".$user_id."'"; - if ($fk_type > 0) $sql.=" AND fk_type = ".$fk_type; + $sql.= " WHERE fk_user = ".(int) $user_id; + if ($fk_type > 0) $sql.=" AND fk_type = ".(int) $fk_type; - dol_syslog(get_class($this).'::getCPforUser', LOG_DEBUG); + dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG); $result = $this->db->query($sql); if($result) { @@ -1799,7 +1784,7 @@ class Holiday extends CommonObject $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; @@ -1807,7 +1792,7 @@ class Holiday extends CommonObject $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager //$tab_result[$i]['type'] = $obj->type; //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; @@ -1826,7 +1811,7 @@ class Holiday extends CommonObject else { // List of vacation balance users - $sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + $sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE cpu.fk_user = u.rowid"; if ($filters) $sql.=$filters; @@ -1845,7 +1830,7 @@ class Holiday extends CommonObject { $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->fk_user; + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; @@ -1853,9 +1838,9 @@ class Holiday extends CommonObject $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager - $tab_result[$i]['type'] = $obj->type; + $tab_result[$i]['type'] = $obj->fk_type; $tab_result[$i]['nb_holiday'] = $obj->nb_holiday; $i++; diff --git a/htdocs/includes/stripe/CHANGELOG.md b/htdocs/includes/stripe/CHANGELOG.md index 26b449ff039..bed9cff5722 100644 --- a/htdocs/includes/stripe/CHANGELOG.md +++ b/htdocs/includes/stripe/CHANGELOG.md @@ -1,5 +1,45 @@ # Changelog +## 6.41.0 - 2019-07-31 +* [#683](https://github.com/stripe/stripe-php/pull/683) Move the List Balance History API to `/v1/balance_transactions` + +## 6.40.0 - 2019-06-27 +* [#675](https://github.com/stripe/stripe-php/pull/675) Add support for `SetupIntent` resource and APIs + +## 6.39.2 - 2019-06-26 +* [#676](https://github.com/stripe/stripe-php/pull/676) Fix exception message in `CustomerBalanceTransaction::update()` + +## 6.39.1 - 2019-06-25 +* [#674](https://github.com/stripe/stripe-php/pull/674) Add new constants for `collection_method` on `Invoice` + +## 6.39.0 - 2019-06-24 +* [#673](https://github.com/stripe/stripe-php/pull/673) Enable request latency telemetry by default + +## 6.38.0 - 2019-06-17 +* [#649](https://github.com/stripe/stripe-php/pull/649) Add support for `CustomerBalanceTransaction` resource and APIs + +## 6.37.2 - 2019-06-17 +* [#671](https://github.com/stripe/stripe-php/pull/671) Add new PHPDoc +* [#672](https://github.com/stripe/stripe-php/pull/672) Add constants for `submit_type` on Checkout `Session` + +## 6.37.1 - 2019-06-14 +* [#670](https://github.com/stripe/stripe-php/pull/670) Add new PHPDoc + +## 6.37.0 - 2019-05-23 +* [#663](https://github.com/stripe/stripe-php/pull/663) Add support for `radar.early_fraud_warning` resource + +## 6.36.0 - 2019-05-22 +* [#661](https://github.com/stripe/stripe-php/pull/661) Add constants for new TaxId types +* [#662](https://github.com/stripe/stripe-php/pull/662) Add constants for BalanceTransaction types + +## 6.35.2 - 2019-05-20 +* [#655](https://github.com/stripe/stripe-php/pull/655) Add constants for payment intent statuses +* [#659](https://github.com/stripe/stripe-php/pull/659) Fix PHPDoc for various nested Account actions +* [#660](https://github.com/stripe/stripe-php/pull/660) Fix various PHPDoc + +## 6.35.1 - 2019-05-20 +* [#658](https://github.com/stripe/stripe-php/pull/658) Use absolute value when checking timestamp tolerance + ## 6.35.0 - 2019-05-14 * [#651](https://github.com/stripe/stripe-php/pull/651) Add support for the Capability resource and APIs diff --git a/htdocs/includes/stripe/README.md b/htdocs/includes/stripe/README.md index 8dca764d7d1..7d1b681c087 100644 --- a/htdocs/includes/stripe/README.md +++ b/htdocs/includes/stripe/README.md @@ -6,7 +6,11 @@ [![License](https://poser.pugx.org/stripe/stripe-php/license.svg)](https://packagist.org/packages/stripe/stripe-php) [![Code Coverage](https://coveralls.io/repos/stripe/stripe-php/badge.svg?branch=master)](https://coveralls.io/r/stripe/stripe-php?branch=master) -You can sign up for a Stripe account at https://stripe.com. +The Stripe PHP library provides convenient access to the Stripe API from +applications written in the PHP language. It includes a pre-defined set of +classes for API resources that initialize themselves dynamically from API +responses which makes it compatible with a wide range of versions of the Stripe +API. ## Requirements @@ -56,7 +60,7 @@ echo $charge; ## Documentation -Please see https://stripe.com/docs/api for up-to-date documentation. +See the [PHP API docs](https://stripe.com/docs/api/php#intro). ## Legacy Version Support @@ -179,6 +183,17 @@ an intermittent network problem: [Idempotency keys][idempotency-keys] are added to requests to guarantee that retries are safe. +### Request latency telemetry + +By default, the library sends request latency telemetry to Stripe. These +numbers help Stripe improve the overall latency of its API for all users. + +You can disable this behavior if you prefer: + +```php +\Stripe\Stripe::setEnableTelemetry(false); +``` + ## Development Get [Composer][composer]. For example, on Mac OS: diff --git a/htdocs/includes/stripe/VERSION b/htdocs/includes/stripe/VERSION index b22907d080c..08c99ad1b68 100644 --- a/htdocs/includes/stripe/VERSION +++ b/htdocs/includes/stripe/VERSION @@ -1 +1 @@ -6.35.0 +6.41.0 diff --git a/htdocs/includes/stripe/init.php b/htdocs/includes/stripe/init.php index 2f6ccfbf67b..e893cfcda90 100644 --- a/htdocs/includes/stripe/init.php +++ b/htdocs/includes/stripe/init.php @@ -76,6 +76,7 @@ require(dirname(__FILE__) . '/lib/CountrySpec.php'); require(dirname(__FILE__) . '/lib/Coupon.php'); require(dirname(__FILE__) . '/lib/CreditNote.php'); require(dirname(__FILE__) . '/lib/Customer.php'); +require(dirname(__FILE__) . '/lib/CustomerBalanceTransaction.php'); require(dirname(__FILE__) . '/lib/Discount.php'); require(dirname(__FILE__) . '/lib/Dispute.php'); require(dirname(__FILE__) . '/lib/EphemeralKey.php'); @@ -104,6 +105,7 @@ require(dirname(__FILE__) . '/lib/Payout.php'); require(dirname(__FILE__) . '/lib/Person.php'); require(dirname(__FILE__) . '/lib/Plan.php'); require(dirname(__FILE__) . '/lib/Product.php'); +require(dirname(__FILE__) . '/lib/Radar/EarlyFraudWarning.php'); require(dirname(__FILE__) . '/lib/Radar/ValueList.php'); require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php'); require(dirname(__FILE__) . '/lib/Recipient.php'); @@ -112,6 +114,7 @@ require(dirname(__FILE__) . '/lib/Refund.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php'); require(dirname(__FILE__) . '/lib/Reporting/ReportType.php'); require(dirname(__FILE__) . '/lib/Review.php'); +require(dirname(__FILE__) . '/lib/SetupIntent.php'); require(dirname(__FILE__) . '/lib/SKU.php'); require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php'); require(dirname(__FILE__) . '/lib/Source.php'); diff --git a/htdocs/includes/stripe/lib/Account.php b/htdocs/includes/stripe/lib/Account.php index 0e84951dcd0..1adc6b79d53 100644 --- a/htdocs/includes/stripe/lib/Account.php +++ b/htdocs/includes/stripe/lib/Account.php @@ -152,8 +152,8 @@ class Account extends ApiResource /** - * @param string|null $id The ID of the account to which the capability belongs. - * @param string|null $capabilityId The ID of the capability to retrieve. + * @param string $id The ID of the account to which the capability belongs. + * @param string $capabilityId The ID of the capability to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -165,8 +165,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the capability belongs. - * @param string|null $capabilityId The ID of the capability to update. + * @param string $id The ID of the account to which the capability belongs. + * @param string $capabilityId The ID of the capability to update. * @param array|null $params * @param array|string|null $opts * @@ -178,7 +178,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the capabilities. + * @param string $id The ID of the account on which to retrieve the capabilities. * @param array|null $params * @param array|string|null $opts * @@ -190,7 +190,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the external account. + * @param string $id The ID of the account on which to create the external account. * @param array|null $params * @param array|string|null $opts * @@ -202,8 +202,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to retrieve. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -215,8 +215,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to update. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to update. * @param array|null $params * @param array|string|null $opts * @@ -228,8 +228,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the external account belongs. - * @param array|null $externalAccountId The ID of the external account to delete. + * @param string $id The ID of the account to which the external account belongs. + * @param string $externalAccountId The ID of the external account to delete. * @param array|null $params * @param array|string|null $opts * @@ -241,7 +241,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the external accounts. + * @param string $id The ID of the account on which to retrieve the external accounts. * @param array|null $params * @param array|string|null $opts * @@ -253,7 +253,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the login link. + * @param string $id The ID of the account on which to create the login link. * @param array|null $params * @param array|string|null $opts * @@ -280,7 +280,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to create the person. + * @param string $id The ID of the account on which to create the person. * @param array|null $params * @param array|string|null $opts * @@ -292,8 +292,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to retrieve. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to retrieve. * @param array|null $params * @param array|string|null $opts * @@ -305,8 +305,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to update. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to update. * @param array|null $params * @param array|string|null $opts * @@ -318,8 +318,8 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account to which the person belongs. - * @param string|null $personId The ID of the person to delete. + * @param string $id The ID of the account to which the person belongs. + * @param string $personId The ID of the person to delete. * @param array|null $params * @param array|string|null $opts * @@ -331,7 +331,7 @@ class Account extends ApiResource } /** - * @param string|null $id The ID of the account on which to retrieve the persons. + * @param string $id The ID of the account on which to retrieve the persons. * @param array|null $params * @param array|string|null $opts * diff --git a/htdocs/includes/stripe/lib/BalanceTransaction.php b/htdocs/includes/stripe/lib/BalanceTransaction.php index cd9b79ae675..403c4aa173e 100644 --- a/htdocs/includes/stripe/lib/BalanceTransaction.php +++ b/htdocs/includes/stripe/lib/BalanceTransaction.php @@ -31,11 +31,36 @@ class BalanceTransaction extends ApiResource use ApiOperations\Retrieve; /** - * @return string The class URL for this resource. It needs to be special - * cased because it doesn't fit into the standard resource pattern. + * Possible string representations of the type of balance transaction. + * @link https://stripe.com/docs/api/balance/balance_transaction#balance_transaction_object-type */ - public static function classUrl() - { - return "/v1/balance/history"; - } + const TYPE_ADJUSTMENT = 'adjustment'; + const TYPE_ADVANCE = 'advance'; + const TYPE_ADVANCE_FUNDING = 'advance_funding'; + const TYPE_APPLICATION_FEE = 'application_fee'; + const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund'; + const TYPE_CHARGE = 'charge'; + const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer'; + const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold'; + const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release'; + const TYPE_ISSUING_TRANSACTION = 'issuing_transaction'; + const TYPE_PAYMENT = 'payment'; + const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund'; + const TYPE_PAYMENT_REFUND = 'payment_refund'; + const TYPE_PAYOUT = 'payout'; + const TYPE_PAYOUT_CANCEL = 'payout_cancel'; + const TYPE_PAYOUT_FAILURE = 'payout_failure'; + const TYPE_REFUND = 'refund'; + const TYPE_REFUND_FAILURE = 'refund_failure'; + const TYPE_RESERVE_TRANSACTION = 'reserve_transaction'; + const TYPE_RESERVED_FUNDS = 'reserved_funds'; + const TYPE_STRIPE_FEE = 'stripe_fee'; + const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee'; + const TYPE_TAX_FEE = 'tax_fee'; + const TYPE_TOPUP = 'topup'; + const TYPE_TOPUP_REVERSAL = 'topup_reversal'; + const TYPE_TRANSFER = 'transfer'; + const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; + const TYPE_TRANSFER_FAILURE = 'transfer_failure'; + const TYPE_TRANSFER_REFUND = 'transfer_refund'; } diff --git a/htdocs/includes/stripe/lib/BankAccount.php b/htdocs/includes/stripe/lib/BankAccount.php index 019a4d87cbd..3fdc9188c64 100644 --- a/htdocs/includes/stripe/lib/BankAccount.php +++ b/htdocs/includes/stripe/lib/BankAccount.php @@ -31,6 +31,16 @@ class BankAccount extends ApiResource use ApiOperations\Delete; use ApiOperations\Update; + /** + * Possible string representations of the bank verification status. + * @link https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status + */ + const STATUS_NEW = 'new'; + const STATUS_VALIDATED = 'validated'; + const STATUS_VERIFIED = 'verified'; + const STATUS_VERIFICATION_FAILED = 'verification_failed'; + const STATUS_ERRORED = 'errored'; + /** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. diff --git a/htdocs/includes/stripe/lib/Charge.php b/htdocs/includes/stripe/lib/Charge.php index 832a07c7c04..43274c5559c 100644 --- a/htdocs/includes/stripe/lib/Charge.php +++ b/htdocs/includes/stripe/lib/Charge.php @@ -11,7 +11,9 @@ namespace Stripe; * @property int $amount_refunded * @property string $application * @property string $application_fee + * @property int $application_fee_amount * @property string $balance_transaction + * @property mixed $billing_details * @property bool $captured * @property int $created * @property string $currency @@ -30,6 +32,8 @@ namespace Stripe; * @property mixed $outcome * @property bool $paid * @property string $payment_intent + * @property string $payment_method + * @property mixed $payment_method_details * @property string $receipt_email * @property string $receipt_number * @property string $receipt_url @@ -86,6 +90,7 @@ class Charge extends ApiResource const DECLINED_INVALID_PIN = 'invalid_pin'; const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available'; const DECLINED_LOST_CARD = 'lost_card'; + const DECLINED_MERCHANT_BLACKLIST = 'merchant_blacklist'; const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available'; const DECLINED_NO_ACTION_TAKEN = 'no_action_taken'; const DECLINED_NOT_PERMITTED = 'not_permitted'; diff --git a/htdocs/includes/stripe/lib/Checkout/Session.php b/htdocs/includes/stripe/lib/Checkout/Session.php index 968d58cf632..33fc6a08ab2 100644 --- a/htdocs/includes/stripe/lib/Checkout/Session.php +++ b/htdocs/includes/stripe/lib/Checkout/Session.php @@ -15,6 +15,7 @@ namespace Stripe\Checkout; * @property bool $livemode * @property string $payment_intent * @property string[] $payment_method_types + * @property string $submit_type * @property string $subscription * @property string $success_url * @@ -27,4 +28,13 @@ class Session extends \Stripe\ApiResource use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\Retrieve; + + /** + * Possible string representations of submit type. + * @link https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type + */ + const SUBMIT_TYPE_AUTO = 'auto'; + const SUBMIT_TYPE_BOOK = 'book'; + const SUBMIT_TYPE_DONATE = 'donate'; + const SUBMIT_TYPE_PAY = 'pay'; } diff --git a/htdocs/includes/stripe/lib/CreditNote.php b/htdocs/includes/stripe/lib/CreditNote.php index 169ed0815c3..66351ffb828 100644 --- a/htdocs/includes/stripe/lib/CreditNote.php +++ b/htdocs/includes/stripe/lib/CreditNote.php @@ -8,6 +8,7 @@ namespace Stripe; * @property string $id * @property string $object * @property int $amount + * @property string $customer_balance_transaction * @property int $created * @property string $currency * @property string $customer diff --git a/htdocs/includes/stripe/lib/Customer.php b/htdocs/includes/stripe/lib/Customer.php index 44f5e6e2f09..6e78f981ee4 100644 --- a/htdocs/includes/stripe/lib/Customer.php +++ b/htdocs/includes/stripe/lib/Customer.php @@ -7,8 +7,8 @@ namespace Stripe; * * @property string $id * @property string $object - * @property int $account_balance * @property mixed $address + * @property int $balance * @property string $created * @property string $currency * @property string $default_source @@ -26,6 +26,7 @@ namespace Stripe; * @property mixed $shipping * @property Collection $sources * @property Collection $subscriptions + * @property string $tax_exempt * @property Collection $tax_ids * * @package Stripe @@ -61,6 +62,7 @@ class Customer extends ApiResource return $savedNestedResources; } + const PATH_BALANCE_TRANSACTIONS = '/balance_transactions'; const PATH_SOURCES = '/sources'; const PATH_TAX_IDS = '/tax_ids'; @@ -264,4 +266,55 @@ class Customer extends ApiResource { return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts); } + + /** + * @param string|null $id The ID of the customer on which to create the balance transaction. + * @param array|null $params + * @param array|string|null $opts + * + * @return ApiResource + */ + public static function createBalanceTransaction($id, $params = null, $opts = null) + { + return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer to which the balance transaction belongs. + * @param string|null $balanceTransactionId The ID of the balance transaction to retrieve. + * @param array|null $params + * @param array|string|null $opts + * + * @return ApiResource + */ + public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null) + { + return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer on which to update the balance transaction. + * @param string|null $balanceTransactionId The ID of the balance transaction to update. + * @param array|null $params + * @param array|string|null $opts + * + * + * @return ApiResource + */ + public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null) + { + return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts); + } + + /** + * @param string|null $id The ID of the customer on which to retrieve the customer balance transactions. + * @param array|null $params + * @param array|string|null $opts + * + * @return Collection The list of customer balance transactions. + */ + public static function allBalanceTransactions($id, $params = null, $opts = null) + { + return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts); + } } diff --git a/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php b/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php new file mode 100644 index 00000000000..06cafcd45c6 --- /dev/null +++ b/htdocs/includes/stripe/lib/CustomerBalanceTransaction.php @@ -0,0 +1,88 @@ +instanceUrl() . '/cancel'; + list($response, $opts) = $this->_request('post', $url, $params, $options); + $this->refreshFrom($response, $opts); + return $this; + } + + /** + * @param array|null $params + * @param array|string|null $options + * + * @return SetupIntent The confirmed setup intent. + */ + public function confirm($params = null, $options = null) + { + $url = $this->instanceUrl() . '/confirm'; + list($response, $opts) = $this->_request('post', $url, $params, $options); + $this->refreshFrom($response, $opts); + return $this; + } +} diff --git a/htdocs/includes/stripe/lib/Source.php b/htdocs/includes/stripe/lib/Source.php index 31b7cf77bba..1e2c8c73565 100644 --- a/htdocs/includes/stripe/lib/Source.php +++ b/htdocs/includes/stripe/lib/Source.php @@ -18,6 +18,7 @@ namespace Stripe; * @property mixed $code_verification * @property int $created * @property string $currency + * @property string $customer * @property mixed $eps * @property string $flow * @property mixed $giropay diff --git a/htdocs/includes/stripe/lib/Stripe.php b/htdocs/includes/stripe/lib/Stripe.php index 027f22fd83c..2397ef9c418 100644 --- a/htdocs/includes/stripe/lib/Stripe.php +++ b/htdocs/includes/stripe/lib/Stripe.php @@ -47,7 +47,7 @@ class Stripe public static $maxNetworkRetries = 0; // @var boolean Whether client telemetry is enabled. Defaults to false. - public static $enableTelemetry = false; + public static $enableTelemetry = true; // @var float Maximum delay between retries, in seconds private static $maxNetworkRetryDelay = 2.0; @@ -55,7 +55,7 @@ class Stripe // @var float Initial delay between retries, in seconds private static $initialNetworkRetryDelay = 0.5; - const VERSION = '6.35.0'; + const VERSION = '6.41.0'; /** * @return string The API key used for requests. diff --git a/htdocs/includes/stripe/lib/Subscription.php b/htdocs/includes/stripe/lib/Subscription.php index 8b57d46b625..f5a46171d81 100644 --- a/htdocs/includes/stripe/lib/Subscription.php +++ b/htdocs/includes/stripe/lib/Subscription.php @@ -13,6 +13,7 @@ namespace Stripe; * @property mixed $billing_thresholds * @property bool $cancel_at_period_end * @property int $canceled_at + * @property string $collection_method * @property int $created * @property int $current_period_end * @property int $current_period_start @@ -31,6 +32,7 @@ namespace Stripe; * @property int $quantity * @property SubscriptionSchedule $schedule * @property int $start + * @property int $start_date * @property string $status * @property float $tax_percent * @property int $trial_end diff --git a/htdocs/includes/stripe/lib/TaxId.php b/htdocs/includes/stripe/lib/TaxId.php index 2993e2d1375..0f72a2ac95f 100644 --- a/htdocs/includes/stripe/lib/TaxId.php +++ b/htdocs/includes/stripe/lib/TaxId.php @@ -12,7 +12,6 @@ namespace Stripe; * @property string $country * @property int $created * @property string $customer - * @property bool $deleted * @property bool $livemode * @property string $type * @property string $value @@ -27,10 +26,12 @@ class TaxId extends ApiResource /** * Possible string representations of a tax id's type. - * @link https://stripe.com/docs/api/customers/tax_id_object#tax_id_object-type + * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type */ const TYPE_AU_ABN = 'au_abn'; const TYPE_EU_VAT = 'eu_vat'; + const TYPE_IN_GST = 'in_gst'; + const TYPE_NO_VAT = 'no_vat'; const TYPE_NZ_GST = 'nz_gst'; const TYPE_UNKNOWN = 'unknown'; diff --git a/htdocs/includes/stripe/lib/Util/Util.php b/htdocs/includes/stripe/lib/Util/Util.php index e21d45dac16..f9f15440023 100644 --- a/htdocs/includes/stripe/lib/Util/Util.php +++ b/htdocs/includes/stripe/lib/Util/Util.php @@ -88,6 +88,7 @@ abstract class Util \Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon', \Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote', \Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer', + \Stripe\CustomerBalanceTransaction::OBJECT_NAME => 'Stripe\\CustomerBalanceTransaction', \Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount', \Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute', \Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey', @@ -117,6 +118,7 @@ abstract class Util \Stripe\Person::OBJECT_NAME => 'Stripe\\Person', \Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan', \Stripe\Product::OBJECT_NAME => 'Stripe\\Product', + \Stripe\Radar\EarlyFraudWarning::OBJECT_NAME => 'Stripe\\Radar\\EarlyFraudWarning', \Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList', \Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem', \Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient', @@ -125,6 +127,7 @@ abstract class Util \Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun', \Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType', \Stripe\Review::OBJECT_NAME => 'Stripe\\Review', + \Stripe\SetupIntent::OBJECT_NAME => 'Stripe\\SetupIntent', \Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU', \Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun', \Stripe\Source::OBJECT_NAME => 'Stripe\\Source', diff --git a/htdocs/includes/stripe/lib/Webhook.php b/htdocs/includes/stripe/lib/Webhook.php index e0ab3021a89..45c7dc0f30a 100644 --- a/htdocs/includes/stripe/lib/Webhook.php +++ b/htdocs/includes/stripe/lib/Webhook.php @@ -24,6 +24,8 @@ abstract class Webhook */ public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE) { + WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance); + $data = json_decode($payload, true); $jsonError = json_last_error(); if ($data === null && $jsonError !== JSON_ERROR_NONE) { @@ -33,8 +35,6 @@ abstract class Webhook } $event = Event::constructFrom($data); - WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance); - return $event; } } diff --git a/htdocs/includes/stripe/lib/WebhookSignature.php b/htdocs/includes/stripe/lib/WebhookSignature.php index 73e70dbd7de..9f8be8777b3 100644 --- a/htdocs/includes/stripe/lib/WebhookSignature.php +++ b/htdocs/includes/stripe/lib/WebhookSignature.php @@ -60,7 +60,7 @@ abstract class WebhookSignature } // Check if timestamp is within tolerance - if (($tolerance > 0) && ((time() - $timestamp) > $tolerance)) { + if (($tolerance > 0) && (abs(time() - $timestamp) > $tolerance)) { throw new Error\SignatureVerification( "Timestamp outside the tolerance zone", $header, diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index b5795a75639..bd556d089cd 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -44,6 +44,11 @@ create table llx_entrepot_extrafields ALTER TABLE llx_entrepot_extrafields ADD INDEX idx_entrepot_extrafields (fk_object); +ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty; +ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit; + + ALTER TABLE llx_c_shipment_mode ADD COLUMN entity integer DEFAULT 1 NOT NULL; ALTER TABLE llx_c_shipment_mode DROP INDEX uk_c_shipment_mode; 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 f639db56ab5..61f4dc544ba 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -285,7 +285,6 @@ DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_acc --update llx_facture_fourn_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; --update llx_expensereport_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; - ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 8e9ceb48d04..742c63d0a6e 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -88,6 +88,10 @@ 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_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/install/step2.php b/htdocs/install/step2.php index 4e645bb6934..6ddd999ea59 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -450,6 +450,11 @@ if ($action == "set") $buffer=trim($buffer); if ($buffer) { + // Replace the prefix in table names + if ($dolibarr_main_db_prefix != 'llx_') + { + $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer); + } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; $resql=$db->query($buffer, 0, 'dml'); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 4b22f512826..8e44c378ba6 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -291,6 +291,7 @@ Modelcsv_quadratus=Export for Quadratus QuadraCompta Modelcsv_ebp=Export for EBP Modelcsv_cogilog=Export for Cogilog Modelcsv_agiris=Export for Agiris +Modelcsv_LDCompta=Export for LD Compta (v9 & higher) (Test) Modelcsv_openconcerto=Export for OpenConcerto (Test) Modelcsv_configurable=Export CSV Configurable Modelcsv_FEC=Export FEC diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4cf9edaa28e..0f22d42327c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1931,3 +1931,4 @@ EndPointFor=End point for %s : %s DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value +AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 4b67ced59c9..5f4a9ff0bba 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -214,6 +214,20 @@ 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 +ToPayOn=To pay on %s +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 ShowPayment=Show payment AlreadyPaid=Already paid AlreadyPaidBack=Already paid back @@ -552,4 +566,4 @@ 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 -BILL_DELETEInDolibarr=Invoice deleted \ No newline at end of file +BILL_DELETEInDolibarr=Invoice deleted diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8e4d42559a8..4c8e761da9a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -90,7 +90,7 @@ ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field ErrorNumRefModel=A reference exists into database (%s) and is not compatible with this numbering rule. Remove record or renamed reference to activate this module. ErrorQtyTooLowForThisSupplier=Quantity too low for this vendor or no price defined on this product for this vendor ErrorOrdersNotCreatedQtyTooLow=Some orders haven't been created because of too-low quantities -ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Home - Setup - Modules to complete. +ErrorModuleSetupNotComplete=Setup of module %s looks to be uncomplete. Go on Home - Setup - Modules to complete. ErrorBadMask=Error on mask ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number ErrorBadMaskBadRazMonth=Error, bad reset value diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index acae5aa73fb..9993e05428f 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -197,4 +197,4 @@ SendReminderForExpiredSubscriptionTitle=Send reminder by email for expired subsc SendReminderForExpiredSubscription=Send reminder by email to members when subscription is about to expire (parameter is number of days before end of subscription to send the remind. It can be a list of days separated by a semicolon, for example '10;5;0;-5') MembershipPaid=Membership paid for current period (until %s) YouMayFindYourInvoiceInThisEmail=You may find your invoice attached to this email -XMembersClosed=%s member(s) closed \ No newline at end of file +XMembersClosed=%s member(s) closed diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 91d1f5a54c5..6905bd41b20 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -64,4 +64,6 @@ ShowInStripe=Show in Stripe StripeUserAccountForActions=User account to use for email notification of some Stripe events (Stripe payouts) StripePayoutList=List of Stripe payouts ToOfferALinkForTestWebhook=Link to setup Stripe WebHook to call the IPN (test mode) -ToOfferALinkForLiveWebhook=Link to setup Stripe WebHook to call the IPN (live mode) \ No newline at end of file +ToOfferALinkForLiveWebhook=Link to setup Stripe WebHook to call the IPN (live mode) +PaymentWillBeRecordedForNextPeriod=Payment will be recorded for the next period. +ClickHereToTryAgain=
Click here to try again... \ No newline at end of file diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index cbca2b2f103..88e5eaf128c 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -76,7 +76,8 @@ WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null StatisticsByLineStatus=Statistics by status of lines -RUM=UMR +RUM=Unique Mandate Reference (UMR) +DateRUM=Mandate signature date RUMLong=Unique Mandate Reference RUMWillBeGenerated=If empty, a UMR (Unique Mandate Reference) will be generated once the bank account information is saved. WithdrawMode=Direct debit mode (FRST or RECUR) diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index de6f26337d7..8bbdfc93f42 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -295,6 +295,7 @@ Modelcsv_openconcerto=Export pour OpenConcerto (Test) Modelcsv_configurable=Export configurable Modelcsv_FEC=Export FEC Modelcsv_Sage50_Swiss=Export pour Sage 50 Suisse +Modelcsv_charlemagne=Export vers Charlemagne ChartofaccountsId=Id plan comptable ## Tools - Init accounting account on product / service diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 1cf435379cd..a223f936638 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -90,7 +90,7 @@ ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis p ErrorNumRefModel=Une référence existe en base (%s) et est incompatible avec cette numérotation. Supprimez la ligne ou renommez la référence pour activer ce module. ErrorQtyTooLowForThisSupplier=Quantité insuffisante pour ce fournisseur ou aucun tarif défini sur ce produit pour ce fournisseur ErrorOrdersNotCreatedQtyTooLow=Certaines commandes n'ont pas été créées en raison de quantités trop faibles -ErrorModuleSetupNotComplete=La configuration des modules semble incomplète. Aller sur la page Accueil - Configuration - Modules pour corriger. +ErrorModuleSetupNotComplete=La configuration du module '%s' semble incomplète. Aller sur la page Accueil - Configuration - Modules pour corriger. ErrorBadMask=Erreur sur le masque ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 9021faf7542..093a1c3ab1e 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -439,13 +439,18 @@ class Livraison extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) - // afin de ne pas perdre les fichiers attaches + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->expedition->dir_output.'/receipt/'.$oldref; $dirdest = $conf->expedition->dir_output.'/receipt/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bf4c40a4176..ff599f7567f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1124,6 +1124,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client); else header("Content-Type: ".$contenttype); + // Security options header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) if (! defined('XFRAMEOPTIONS_ALLOWALL')) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) @@ -2319,6 +2320,51 @@ if (! function_exists("llxFooter")) print "\n\n"; print ''."\n"; + // Add code for the asynchronous anonymous first ping (for telemetry) + if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) + { + if (empty($conf->global->MAIN_FIRST_PING_OK_DATE) + || (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID)) + || GETPOST('forceping', 'alpha')) + { + print "\n".''."\n"; + print "\n\n"; + ?> + + \n"; print "\n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index deda54bf996..daf77674190 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -435,7 +435,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) 'dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'dol_company' => $mysoc->name, // Usefull when using multicompany - 'dol_tax_num' => $taxinfo, + 'dol_tax_num' => $vatnumber, 'ipaddress'=> getUserRemoteIP() ); @@ -460,47 +460,57 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); $stripeacc = $stripe->getStripeAccount($service); - $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + if (empty($customer)) + { + $error++; + dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERR, 0, '_stripe'); + setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors'); + $action=''; + } // Create Stripe card from Token - if ($savesource) { - $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); - } else { - $card = $stripeToken; - } - - if (empty($card)) + if (! $error) { - $error++; - dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to create card record', null, 'errors'); - $action=''; - } - else - { - if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (! empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (! empty($dol_type)) $metadata["dol_type"] = $dol_type; + if ($savesource) { + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { + $card = $stripeToken; + } - dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'customer' => $customer->id, - 'source' => $card, - 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action=''; - } + if (empty($card)) + { + $error++; + dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to create card record', null, 'errors'); + $action=''; + } + else + { + if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (! empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (! empty($dol_type)) $metadata["dol_type"] = $dol_type; + + dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'customer' => $customer->id, + 'source' => $card, + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action=''; + } + } } } else @@ -1685,6 +1695,7 @@ if ($action != 'dopayment') { $langs->load("members"); print '
'.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
'; + print ''.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
'; } // Buttons for all payments registration methods @@ -1692,26 +1703,51 @@ if ($action != 'dopayment') if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of paybox - print '
'; + print '
'; print '
'; print ''.$langs->trans("CreditOrDebitCard").''; 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 '
'; @@ -1724,6 +1760,19 @@ if ($action != 'dopayment') //print ''.$langs->trans("PayPalBalance").'">'; } print '
'; + print ' + '; } } } @@ -1886,7 +1935,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment // JS Code for Stripe if (empty($stripearrayofkeys['publishable_key'])) { - print info_admin($langs->trans("ErrorModuleSetupNotComplete", "stripe"), 0, 0, 'error'); + $langs->load("errors"); + print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); } else { diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index c4e4ad68a23..9e68958712e 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -235,7 +235,7 @@ elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$lo // Output html code for logo if ($urllogo) { - print '
'; print '
'; @@ -246,6 +246,17 @@ print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; $key='ONLINE_PAYMENT_MESSAGE_KO'; if (! empty($conf->global->$key)) print $conf->global->$key; +$type = GETPOST('s', 'alpha'); +$ref = GETPOST('ref', 'none'); +$tag = GETPOST('tag', 'alpha'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; +if ($type || $tag) +{ + $urlsubscription =getOnlinePaymentUrl(0, ($type?$type:'free'), $ref, $FinalPaymentAmt, $tag); + + print $langs->trans("ClickHereToTryAgain", $urlsubscription); +} + print "\n
\n"; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index d0baa948950..c939ea44abf 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -643,13 +643,18 @@ class Reception extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref) - // in order not to lose the attached files + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->reception->dir_output.'/'.$oldref; $dirdest = $conf->reception->dir_output.'/'.$newref; - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 2e4085200a2..02565a23dd0 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 @@ -80,47 +81,71 @@ if ($socid > 0) // Special for thirdparty * Actions */ -if ($action == 'add_element_resource' && ! $cancel) -{ - $res = 0; - if (! ($resource_id > 0)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); - $action=''; - } - else - { - $objstat = fetchObjectByElement($element_id, $element, $element_ref); - $objstat->element = $element; // For externals module, we need to keep @xx - $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); - } - if (! $error && $res > 0) - { - setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id); - exit; - } - elseif ($objstat) - { - setEventMessages($objstat->error, $objstat->errors, 'errors'); - } -} +$parameters = array('resource_id' => $resource_id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -// Update ressource -if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha') ) +if (empty($reshook)) { - $res = $object->fetch_element_resource($lineid); - if($res) + if ($action == 'add_element_resource' && ! $cancel) { - $object->busy = $busy; - $object->mandatory = $mandatory; + $res = 0; + if (! ($resource_id > 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); + $action=''; + } + else + { + $objstat = fetchObjectByElement($element_id, $element, $element_ref); + $objstat->element = $element; // For externals module, we need to keep @xx + $res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory); + } + if (! $error && $res > 0) + { + setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id); + exit; + } + elseif ($objstat) + { + setEventMessages($objstat->error, $objstat->errors, 'errors'); + } + } - $result = $object->update_element_resource($user); + // Update ressource + if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel', 'alpha') ) + { + $res = $object->fetch_element_resource($lineid); + if($res) + { + $object->busy = $busy; + $object->mandatory = $mandatory; + + $result = $object->update_element_resource($user); + + if ($result >= 0) + { + setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + // Delete a resource linked to an element + if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && $confirm === 'yes') + { + $result = $object->delete_resource($lineid, $element); if ($result >= 0) { - setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); + setEventMessages($langs->trans('RessourceLineSuccessfullyDeleted'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); exit; } @@ -131,28 +156,6 @@ if ($action == 'update_linked_resource' && $user->rights->resource->write && !GE } } -// Delete a resource linked to an element -if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && $confirm === 'yes') -{ - $result = $object->delete_resource($lineid, $element); - - if ($result >= 0) - { - setEventMessages($langs->trans('RessourceLineSuccessfullyDeleted'), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -$parameters=array('resource_id'=>$resource_id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - $parameters=array('resource_id'=>$resource_id); $reshook=$hookmanager->executeHooks('getElementResources', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -474,29 +477,46 @@ else $linked_resources = $object->getElementResources($element, $element_id, $resource_obj); - - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) + // Output template part (modules that overwrite templates must declare this into descriptor) + $defaulttpldir='/core/tpl'; + $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir)); + + foreach($dirtpls as $module => $reldir) { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'))) + { + $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php'; + } + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } if ($mode != 'add' || $resource_obj != $resource_type) { - //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); - - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'))) + foreach($dirtpls as $module => $reldir) { - $res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; + if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'))) + { + $tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php'); + } + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php'; + } + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 725a5176a20..7aef3c0cd09 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -383,7 +383,7 @@ if (empty($reshook)) } else $object->canvas=$canvas; - if (GETPOST("private") == 1) // Ask to create a contact + if (GETPOST("private", 'int') == 1) // Ask to create a contact { $object->particulier = GETPOST("private"); @@ -1172,13 +1172,18 @@ else // If javascript on, we show option individual if ($conf->use_javascript_ajax) { - print ''.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).''; - print ''; - print ''; - // Title - print ''.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; - print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').''; - print ''; + if (! empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + { + // Firstname + print ''.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).''; + print ''; + print ''; + + // Title + print ''.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; + print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').''; + print ''; + } } // Alias names (commercial, trademark or alias names) diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 0c4da8aa103..6f957be32d7 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -46,7 +46,7 @@ class CompanyBankAccount extends Account * @var integer */ public $datec; - + /** * Date modification record (tms) * @@ -217,7 +217,7 @@ class CompanyBankAccount extends Account if (empty($id) && empty($socid)) return -1; $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) $sql.= " WHERE rowid = ".$id; if ($socid) @@ -255,6 +255,7 @@ class CompanyBankAccount extends Account $this->datem = $this->db->jdate($obj->datem); $this->rum = $obj->rum; $this->frstrecur = $obj->frstrecur; + $this->date_rum = $this->db->jdate($obj->date_rum); } $this->db->free($resql); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9ddbed6c9b0..2ee5f5bedf5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -224,21 +224,25 @@ $object = new Societe($db); * Actions */ -if ($action=="change") +if ($action=="change") // Change customer for TakePOS { $idcustomer = GETPOST('idcustomer', 'int'); $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant - $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS-".$place.")'"; + // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically + $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); - ?> - - + + owner_address = GETPOST('owner_address', 'alpha'); $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha'); $companybankaccount->rum = GETPOST('rum', 'alpha'); + $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); if (empty($companybankaccount->rum)) { $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + } + if (empty($companybankaccount->date_rum)) + { $companybankaccount->date_rum = dol_now(); } @@ -268,6 +272,7 @@ if (empty($reshook)) $companybankaccount->owner_address = GETPOST('owner_address', 'alpha'); $companybankaccount->frstrecur = GETPOST('frstrecur'); $companybankaccount->rum = GETPOST('rum', 'alpha'); + $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); $companybankaccount->datec = dol_now(); $companybankaccount->status = 1; @@ -1208,6 +1213,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (! empty($conf->prelevement->enabled)) { print_liste_field_titre("RUM"); + print_liste_field_titre("DateRUM"); print_liste_field_titre("WithdrawMode"); } print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center '); @@ -1257,8 +1263,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (! empty($rib->iban)) { if (! checkIbanForAccount($rib)) { print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); - } else { - print ' '.img_picto($langs->trans("IbanValid"), 'info'); } } print ''; @@ -1267,8 +1271,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (! empty($rib->bic)) { if (! checkSwiftForAccount($rib)) { print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); - } else { - print ' '.img_picto($langs->trans("SwiftValid"), 'info'); } } print ''; @@ -1279,6 +1281,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' //print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''; print ''.$rib->rum.''; + print ''.dol_print_date($rib->date_rum, 'day').''; + // FRSTRECUR print ''.$rib->frstrecur.''; } @@ -1531,6 +1535,9 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print ''.$langs->trans("RUM").''; print ''; + print ''.$langs->trans("DateRUM").''; + print ''.$form->selectDate(GETPOST('date_rum')?GETPOST('date_rum'):$companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').''; + print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha')?GETPOST('frstrecur', 'alpha'):$companybankaccount->frstrecur), 0); @@ -1675,6 +1682,9 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print ''.$langs->trans("RUM").''; print '
'.$langs->trans("RUMWillBeGenerated").'
'; + print ''.$langs->trans("DateRUM").''; + print ''.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0, 0, 1, 'date_rum').''; + print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 3966a3f439f..c2b2143f277 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -55,6 +55,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -64,6 +67,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -194,7 +200,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; @@ -267,7 +273,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
'; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 92c6335cd29..efd79d25583 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -177,6 +177,7 @@ class Stripe extends CommonObject } catch(Exception $e) { + // For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.' $this->error = $e->getMessage(); } } @@ -404,7 +405,7 @@ class Stripe extends CommonObject if ($conf->entity!=$conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) { - $dataforintent["application_fee"] = $stripefee; + $dataforintent["application_fee_amount"] = $stripefee; } if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) { @@ -731,7 +732,7 @@ class Stripe extends CommonObject ); if ($conf->entity!=$conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) { - $paymentarray["application_fee"] = $stripefee; + $paymentarray["application_fee_amount"] = $stripefee; } if ($societe->email && $usethirdpartyemailforreceiptemail) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 2725cd18190..a84f18f5b7b 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1494,16 +1494,20 @@ class SupplierProposal extends CommonObject // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); + // 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; + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; - - if (file_exists($dirsource)) + if (! $error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); @@ -2502,7 +2506,7 @@ class SupplierProposal extends CommonObject else { $langs->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 2b29f46120d..0a91e303a53 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/takepos/admin/setup.php + * \file htdocs/takepos/admin/terminal.php * \ingroup takepos * \brief Setup page for TakePos module */ @@ -125,30 +125,36 @@ print ''; print ''.$langs->trans("Parameters").''.$langs->trans("Value").''; print "\n"; -print ''.$langs->trans("CashDeskThirdPartyForSell").''; -print ''; +print ''.$langs->trans("CashDeskThirdPartyForSell").''; +print ''; 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 ''; + +$atleastonefound = 0; if (! empty($conf->banque->enabled)) { print ''.$langs->trans("CashDeskBankAccountForSell").''; - print ''; + 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 ''; print ''.$langs->trans("CashDeskBankAccountForCheque").''; - print ''; + 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 ''; print ''.$langs->trans("CashDeskBankAccountForCB").''; - print ''; + 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 ''; 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 ''.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->libelle).''; - print ''; + 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); print ''; @@ -159,7 +165,7 @@ if (! empty($conf->stock->enabled)) { print ''.$langs->trans("CashDeskDoNotDecreaseStock").''; // Force warehouse (this is not a default value) - print ''; + print ''; if (empty($conf->productbatch->enabled)) { print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); } @@ -177,7 +183,7 @@ if (! empty($conf->stock->enabled)) print ''.$langs->trans("CashDeskIdWareHouse").''; // Force warehouse (this is not a default value) - print ''; + print ''; if (! $disabled) { print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled); @@ -191,6 +197,12 @@ if (! empty($conf->stock->enabled)) } print ''; + +if ($atleastonefound == 0 && ! empty($conf->banque->enabled)) +{ + print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error'); +} + print '
'; print '
'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 48b637ee9fa..dfa058068ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -42,7 +42,7 @@ $langs->loadLangs(array("bills", "cashdesk")); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT==1 && $conf->browser->layout == 'phone') { @@ -209,9 +209,21 @@ if (($action=="addline" || $action=="freezone") && $placeid == 0) $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; - $placeid = $invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; - $db->query($sql); + if ($invoice->socid <= 0) + { + $langs->load('errors'); + dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); + } + else + { + $placeid = $invoice->create($user); + if ($placeid < 0) + { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + $sql="UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; + $db->query($sql); + } } if ($action == "addline") diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 7e55bbc5936..7260bc81a58 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/takepos/floors.php + * \file htdocs/takepos/takepos.php * \ingroup takepos * \brief Main TakePOS screen */ @@ -359,7 +359,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");?>"}); } @@ -626,6 +626,7 @@ $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; $sql.= " AND active = 1"; $sql.= " ORDER BY libelle"; + $resql = $db->query($sql); $paiementsModes = array(); if ($resql){ @@ -640,7 +641,8 @@ if ($resql){ } } if (empty($paiementsModes)) { - setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); + $langs->load('errors'); + setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors'); } if (count($maincategories)==0) { setEventMessages($langs->trans("TakeposNeedsCategories"), null, 'errors'); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 902a2117e36..d0a0c5958ef 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -151,6 +151,9 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment { color: #fff; border-radius: 4px; } +div.buttonpayment input:focus { + color: #008; +} .buttonpaymentsmall { font-size: 0.65em; padding-left: 5px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9fad375eade..8999a73aaea 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -376,6 +376,9 @@ div.buttonpayment input { color: #333; cursor: pointer; } +div.buttonpayment input:focus { + color: #008; +} input.buttonpaymentcb { background-image: url(); background-size: 26px; diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 1395d8acf2b..78d351a8dae 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -218,17 +218,16 @@ class Tickets extends DolibarrApi * Get a list of tickets * * @param int $socid Filter list with thirdparty ID - * @param string $mode Use this param to filter list * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" * * @return array Array of ticket objects * */ - public function index($socid = 0, $mode = "", $sortfield = "s.rowid", $sortorder = "ASC", $limit = 0, $page = 0, $sqlfilters = '') + public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -243,51 +242,25 @@ class Tickets extends DolibarrApi $search_sale = DolibarrApiAccess::$user->id; } - $sql = "SELECT s.rowid"; + $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) } - $sql.= " FROM ".MAIN_DB_PREFIX."ticket as s"; + $sql.= " FROM ".MAIN_DB_PREFIX."ticket as t"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale } - $sql.= ' WHERE s.entity IN ('.getEntity('ticket', 1).')'; + $sql.= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql.= " AND s.fk_soc = sc.fk_soc"; + $sql.= " AND t.fk_soc = sc.fk_soc"; } if ($socid > 0) { - $sql.= " AND s.fk_soc = ".$socid; + $sql.= " AND t.fk_soc = ".$socid; } if ($search_sale > 0) { - $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - } - - // Example of use $mode - if ($mode == 'new') { - $sql.= " AND s.fk_statut IN (0)"; - } - if ($mode == 'read') { - $sql.= " AND s.fk_statut IN (1)"; - } - if ($mode == 'answered') { - $sql.= " AND s.fk_statut IN (3)"; - } - if ($mode == 'assign') { - $sql.= " AND s.fk_statut IN (4)"; - } - if ($mode == 'inprogress') { - $sql.= " AND s.fk_statut IN (5)"; - } - if ($mode == 'waiting') { - $sql.= " AND s.fk_statut IN (6)"; - } - if ($mode == 'closed') { - $sql.= " AND s.fk_statut IN (8)"; - } - if ($mode == 'deleted') { - $sql.= " AND s.fk_statut IN (9)"; + $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter @@ -344,7 +317,6 @@ class Tickets extends DolibarrApi * * @param array $request_data Request datas * @return int ID of ticket - * */ public function post($request_data = null) { @@ -364,9 +336,11 @@ class Tickets extends DolibarrApi if (empty($this->ticket->track_id)) { $this->ticket->track_id = generate_random_id(16); } - if (! $this->ticket->create(DolibarrApiAccess::$user)) { - throw new RestException(500); + + if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); } + return $this->ticket->id; } @@ -561,8 +535,12 @@ class Tickets extends DolibarrApi "lastname", "firstname", "civility_id", + "canvas", "cache_msgs_ticket", "cache_logs_ticket", + "cache_types_tickets", + "cache_category_tickets", + "regeximgext", "statuts_short", "statuts" ); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index f40d3afce33..2a4195cb07b 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -533,7 +533,9 @@ foreach($object->fields as $key => $val) } print ''; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); - print Form::multiselectarray('search_fk_statut', $arrayofstatus, array_values($search[$key]), 0, 0, 'minwidth150', 1, 0, '', '', ''); + $selectedarray = null; + if ($search[$key]) $selectedarray = array_values($search[$key]); + print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); print ''; } elseif ($key == "fk_soc") diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 46e42c351c7..2ad328b5a88 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -120,7 +120,7 @@ if ($id > 0) if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete").''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).''; } else { @@ -161,7 +161,7 @@ if ($id > 0) if (empty($url)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete").''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).''; } else { diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index b77beb001b3..69ab71e62ed 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -172,7 +172,9 @@ if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); // Security: This wrapper is for images. We do not allow type/html -if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 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.', 0, 0, 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.', 0, 0, 1); // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 3c066380b09..443d77e2382 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -232,7 +232,8 @@ class FactureTest extends PHPUnit\Framework\TestCase 'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification', 'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', 'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva', - 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx' + 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx', + 'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement' ) ); $this->assertEquals($arraywithdiff, array()); // Actual, Expected diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index 7e3fc6a8069..ce3312ba441 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -351,4 +351,18 @@ class HolidayTest extends PHPUnit\Framework\TestCase $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning $this->assertTrue($result, 'result should be true, there is no overlapping'); } + + /** + * testUpdateBalance + * + * @return void + */ + public function testUpdateBalance() + { + $localobjecta=new Holiday($this->savdb); + + $localobjecta->updateConfCP('lastUpdate', '20100101120000'); + + $localobjecta->updateBalance(); + } }