diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index b0adb2e2ad188..1f38171f19937 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -641,8 +641,8 @@ 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 +675,7 @@ 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 616c8697c61ac..aecd5a1d82efe 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -789,7 +789,7 @@ // 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 @@ // 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 < $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/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 7e7f40ddfbb32..8e1f36bbf4183 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -469,14 +469,15 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss */ 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 @@ public function createStd(User $user, $notrigger = false, $mode = '') $now = dol_now(); // Check parameters - // Put here code to add control on parameters values + $this->journal_label = $langs->trans($this->journal_label); // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6138fd395f011..a6fd91a421078 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1187,7 +1187,7 @@ function initfieldrequired() } // 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/type.php b/htdocs/adherents/type.php index 2c8c108b3d5dc..96b043fcf7b6a 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -342,7 +342,7 @@ // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print ""; @@ -775,7 +775,7 @@ // Morphy $morphys[""] = $langs->trans("MorPhy"); $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); + $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans("MemberNature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print ""; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 61acf6e3a89ef..378d6087cc71d 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -247,7 +247,7 @@ } // Get the bank account dedicated to this point of sale module/terminal - $vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse; + $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 5ba7232dc95cc..38a5f88842a17 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -190,7 +190,7 @@ 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/sociales/list.php b/htdocs/compta/sociales/list.php index 7e25d8c3423e5..baa1f57a3074e 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -187,7 +187,7 @@ 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 @@ 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 9bf94a16b34fb..af215902d0ecd 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -90,7 +90,7 @@ 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 @@ 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/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0e6b0befef9a2..09130bb130a79 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1411,7 +1411,7 @@ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $ // 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 @@ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $ $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/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 1311264f7fb00..0a60d9dc0aeca 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -594,16 +594,25 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji // 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 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji 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 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji } // 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 00db9096bca45..10b2a5662f300 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -621,16 +621,25 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji // 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 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji 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 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval, $this->cachefieldtable[$field.'@'.$table])) + if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) { - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table); + $tableforerror = $table; + if(! empty($filter)) $tableforerror.= ':'.$filter; + $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 092d5ac10b7a9..4b819a5bcae0b 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -425,8 +425,8 @@ public function __construct($db) $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product'); - $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*" - ); + $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"); + $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0'); $this->import_convertvalue_array[$r]=array( 'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'), @@ -444,7 +444,10 @@ public function __construct($db) $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' ); $this->import_convertvalue_array[$r]=array( @@ -463,7 +466,10 @@ public function __construct($db) $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur'); - $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*" + $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"); + $this->import_regex_array[$r]=array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0' ); $this->import_convertvalue_array[$r]=array( diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index bf46ecb989029..75c6f72e1df81 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -255,6 +255,25 @@ { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } + + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + { + ?> + + select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - ?> - - global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> + + '; echo ''; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index bdbed6b202731..cc05bf686c309 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1584,9 +1584,9 @@ print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); print ''; } - - $indiceAsked++; } + + $indiceAsked++; } print ""; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 533f6c9c74801..0245073a06012 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1438,45 +1438,30 @@ public function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') $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) - { - dol_syslog("We update leavefor everybody for type ".$key, LOG_DEBUG); + // Update each user counter + foreach ($users as $userCounter) { + $nbDaysToAdd = $typeleaves[$userCounter['type']]['newByMonth']; + if(empty($nbDaysToAdd)) continue; - $i = 0; - while ($i < $nbUser) - { - $now_holiday = $this->getCPforUser($users[$i]['rowid'], $val['rowid']); - $new_solde = $now_holiday + $nb_holiday; + dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); - // We add a log for each user - $this->addLogCP($user->id, $users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $new_solde, $val['rowid']); - - $i++; - } + $nowHoliday = $userCounter['nb_holiday']; + $newSolde = $nowHoliday + $nbDaysToAdd; - // 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']; + // We add a log for each user + $this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); - $result= $this->db->query($sql2); + $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); - if (! $result) - { - dol_print_error($this->db); - break; - } + if ($result < 0) + { + $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 @@ public function getCPforUser($user_id, $fk_type = 0) { $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 @@ public function fetchUsers($stringlist = true, $type = true, $filters = '') $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 @@ public function fetchUsers($stringlist = true, $type = true, $filters = '') $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 @@ public function fetchUsers($stringlist = true, $type = true, $filters = '') 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 @@ public function fetchUsers($stringlist = true, $type = true, $filters = '') { $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 @@ public function fetchUsers($stringlist = true, $type = true, $filters = '') $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/install/step2.php b/htdocs/install/step2.php index 4e645bb69349a..dc820633395e1 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -450,6 +450,11 @@ $buffer=trim($buffer); if ($buffer) { + // Replace the prefix in table names + if ($dolibarr_main_db_prefix != 'llx_') + { + $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer); + } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; $resql=$db->query($buffer, 0, 'dml'); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 725a5176a204c..7aef3c0cd09ba 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -383,7 +383,7 @@ } else $object->canvas=$canvas; - if (GETPOST("private") == 1) // Ask to create a contact + if (GETPOST("private", 'int') == 1) // Ask to create a contact { $object->particulier = GETPOST("private"); @@ -1172,13 +1172,18 @@ function init_supplier_categ() { // If javascript on, we show option individual if ($conf->use_javascript_ajax) { - print ''.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).''; - 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/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 770678aae15ad..c2b2143f2774f 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -55,6 +55,9 @@ if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY", GETPOST('STRIPE_TEST_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_ID", GETPOST('STRIPE_TEST_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY", GETPOST('STRIPE_TEST_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -64,6 +67,9 @@ if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY", GETPOST('STRIPE_LIVE_SECRET_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); + if (! $result > 0) + $error ++; + $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_ID", GETPOST('STRIPE_LIVE_WEBHOOK_ID', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; $result = dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY", GETPOST('STRIPE_LIVE_WEBHOOK_KEY', 'alpha'), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index b77beb001b39d..69ab71e62ed2e 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -172,7 +172,9 @@ function llxFooter() else $type=dol_mimetype($original_file); // Security: This wrapper is for images. We do not allow type/html -if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 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/HolidayTest.php b/test/phpunit/HolidayTest.php index 7e3fc6a80696d..3e7ddfb7f0f01 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -351,4 +351,19 @@ public function testVerifDateHolidayCP() $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(); + } + }