Skip to content

Commit

Permalink
Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 30, 2019
2 parents 10344d9 + 192fb45 commit 34f78c5
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 103 deletions.
6 changes: 3 additions & 3 deletions htdocs/accountancy/bookkeeping/card.php
Expand Up @@ -641,8 +641,8 @@
print '<td>' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_operation. '</td>';
print '<td class="right">' . price($line->debit) . '</td>';
print '<td class="right">' . price($line->credit) . '</td>';
print '<td class="nowrap right">' . price($line->debit) . '</td>';
print '<td class="nowrap right">' . price($line->credit) . '</td>';

print '<td class="center">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
Expand Down Expand Up @@ -675,7 +675,7 @@
print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, '');
print '</td>';
print '<td>';
// 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))
{
Expand Down
8 changes: 4 additions & 4 deletions htdocs/accountancy/bookkeeping/list.php
Expand Up @@ -789,7 +789,7 @@
// Amount debit
if (! empty($arrayfields['t.debit']['checked']))
{
print '<td class="right">' . ($line->debit ? price($line->debit) : ''). '</td>';
print '<td class="nowrap right">' . ($line->debit ? price($line->debit) : ''). '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
$totalarray['totaldebit'] += $line->debit;
Expand All @@ -798,7 +798,7 @@
// Amount credit
if (! empty($arrayfields['t.credit']['checked']))
{
print '<td class="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
$totalarray['totalcredit'] += $line->credit;
Expand Down Expand Up @@ -879,8 +879,8 @@
if ($num < $limit && empty($offset)) print '<td class="left">'.$langs->trans("Total").'</td>';
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
}
elseif ($totalarray['totaldebitfield'] == $i) print '<td class="right">'.price($totalarray['totaldebit']).'</td>';
elseif ($totalarray['totalcreditfield'] == $i) print '<td class="right">'.price($totalarray['totalcredit']).'</td>';
elseif ($totalarray['totaldebitfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totaldebit']).'</td>';
elseif ($totalarray['totalcreditfield'] == $i) print '<td class="nowrap right">'.price($totalarray['totalcredit']).'</td>';
else print '<td></td>';
}
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
Expand Down
7 changes: 4 additions & 3 deletions htdocs/accountancy/class/bookkeeping.class.php
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.' (';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/card.php
Expand Up @@ -1187,7 +1187,7 @@ function initfieldrequired()
}
// Morphy
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy));
print "</td></tr>";
Expand Down
4 changes: 2 additions & 2 deletions htdocs/adherents/type.php
Expand Up @@ -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 '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>";
Expand Down Expand Up @@ -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 '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/cashcontrol/cashcontrol_card.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/charges/index.php
Expand Up @@ -190,7 +190,7 @@
print $socialcontrib->getNomUrl(1, '20');
print '</td>';
// Type
print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
print '<td><a href="../sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
// Expected to pay
print '<td class="right">'.price($obj->total).'</td>';
// Ref payment
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/sociales/list.php
Expand Up @@ -187,7 +187,7 @@

if ($year)
{
$center=($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":"");
$center=($year?"<a href='list.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='list.php?year=".($year+1)."'>".img_next()."</a>":"");
print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
}
else
Expand Down Expand Up @@ -281,7 +281,7 @@
print '<td align="center">';
if ($obj->periode)
{
print '<a href="index.php?year='.strftime("%Y", $db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').'</a>';
print '<a href="list.php?year='.strftime("%Y",$db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').'</a>';
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/sociales/payments.php
Expand Up @@ -90,7 +90,7 @@

if ($mode != 'sconly')
{
$center=($year?'<a href="index.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="index.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
$center=($year?'<a href="list.php?year='.($year-1).$param.'">'.img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a> ".$langs->trans("Year").' '.$year.' <a href="list.php?year='.($year+1).$param.'">'.img_next($langs->trans("Next"), 'class="valignbottom"')."</a>":"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
}
else
Expand Down Expand Up @@ -181,7 +181,7 @@
print $socialcontrib->getNomUrl(1, '20');
print '</td>';
// Type
print '<td><a href="../sociales/index.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
print '<td><a href="../sociales/list.php?filtre=cs.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
// Date
$date=$obj->periode;
if (empty($date)) $date=$obj->date_ech;
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -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\$';

Expand Down Expand Up @@ -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 ";
}
}

Expand Down
23 changes: 17 additions & 6 deletions htdocs/core/modules/import/import_csv.modules.php
Expand Up @@ -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)
{
Expand All @@ -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++;
}
}
Expand All @@ -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++;
Expand Down
23 changes: 17 additions & 6 deletions htdocs/core/modules/import/import_xlsx.modules.php
Expand Up @@ -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)
{
Expand All @@ -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++;
}
}
Expand All @@ -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++;
Expand Down
14 changes: 10 additions & 4 deletions htdocs/core/modules/modCategorie.class.php
Expand Up @@ -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'),
Expand All @@ -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(
Expand All @@ -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(
Expand Down
50 changes: 36 additions & 14 deletions htdocs/core/tpl/objectline_create.tpl.php
Expand Up @@ -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))
{
?>
<script type="text/javascript">
$(document).ready(function(){
// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
$(document).on('focus', '.select2-selection.select2-selection--single', function (e) {
console.log('focus on a select2');
if ($(this).attr('aria-labelledby') == 'select2-idprod-container')
{
console.log('open combo');
$('#idprod').select2('open');
}
});
});
</script>
<?php
}
}
else
{
Expand All @@ -277,21 +296,24 @@
}

$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300');
?>
<script type="text/javascript">

$(document).ready(function(){

$(document).on('keypress',function(e) {
if ($('input:focus').length == 0) {
$('#idprodfournprice').select2('open');
}
});


});
</script>
<?php
if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
{
?>
<script type="text/javascript">
$(document).ready(function(){
// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
$(document).on('focus', '.select2-selection.select2-selection--single', function (e) {
//console.log('focus on a select2');
if ($(this).attr('aria-labelledby') == 'select2-idprodfournprice-container')
{
$('#idprodfournprice').select2('open');
}
});
});
</script>
<?php
}
}
echo '<input type="hidden" name="pbq" id="pbq" value="">';
echo '</span>';
Expand Down

0 comments on commit 34f78c5

Please sign in to comment.