Skip to content

Commit

Permalink
Merge pull request #1 from Dolibarr/develop
Browse files Browse the repository at this point in the history
get new version
  • Loading branch information
gschratzer committed Aug 25, 2015
2 parents 0aabf5e + a54589c commit 6b85a49
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 21 deletions.
33 changes: 28 additions & 5 deletions htdocs/comm/prospect/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@

// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('thirdparty');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');

// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
Expand All @@ -174,6 +175,7 @@
$search_datec="";
$search_categ="";
$search_status="";
$search_array_options=array();
}

if ($search_status=='') $search_status=1; // always display active customer first
Expand Down Expand Up @@ -256,6 +258,19 @@
$sortfield = "s.nom";
$sortorder = "ASC";
}
// Extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
Expand All @@ -269,6 +284,7 @@
}
$sql.= " ORDER BY $sortfield $sortorder, s.nom ASC";
$sql.= $db->plimit($conf->liste_limit+1, $offset);
//print $sql;

dol_syslog('comm/prospect/list.php', LOG_DEBUG);
$resql = $db->query($sql);
Expand Down Expand Up @@ -302,9 +318,15 @@
}
if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
if ($search_categ != '') $param.='&search_categ='.$search_categ;
if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ);
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
if ($search_status != '') $param.='&search_status='.$search_status;
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
// $param and $urladd should have the same value
$urladd = $param;

Expand Down Expand Up @@ -420,7 +442,7 @@
{
$arraystcomm[$val['id']]=$val['label'];
}
print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, 1);
print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
print '</td>';

print '<td class="liste_titre" align="center">';
Expand All @@ -434,9 +456,10 @@
{
if ($val)
{
print '<td class="liste_titre">';
//print $extrafields->showInputField($key, $array_options[$key], '', '', 'search_', 4);
print '</td>';
$crit=$search_array_options['search_options_'.$key];
print '<td class="liste_titre">';
print $extrafields->showInputField($key, $crit, '', '', 'search_', 4);
print '</td>';
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
$search_montant_ht='';
$search_montant_ttc='';
$search_status='';
$day='';
$year='';
$month='';
}
Expand Down Expand Up @@ -350,7 +351,7 @@
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ttc" value="'.$search_montant_ttc.'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="right">';
$liststatus=array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid"), '3'=>$langs->trans("Cancel"));
$liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
print $form->selectarray('search_status', $liststatus, $search_status, 1);
print '</td>';
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
Expand Down
29 changes: 28 additions & 1 deletion htdocs/compta/paiement/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

$langs->load("bills");
$langs->load("compta");
Expand All @@ -36,6 +38,10 @@
$facid =GETPOST('facid','int');
$socid =GETPOST('socid','int');
$userid=GETPOST('userid','int');
$day = GETPOST('day','int');
$month = GETPOST('month','int');
$year = GETPOST('year','int');

if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture',$facid,'');

Expand Down Expand Up @@ -66,6 +72,9 @@
$search_amount="";
$search_paymenttype="";
$search_company="";
$day='';
$year='';
$month='';
}

// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
Expand All @@ -81,6 +90,7 @@
llxHeader('', $langs->trans('ListPayment'));

$form=new Form($db);
$formother=new FormOther($db);

if (GETPOST("orphelins"))
{
Expand Down Expand Up @@ -141,6 +151,19 @@
else $sql.= " AND f.fk_user_author = ".$userid;
}
// Search criteria
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(p.datep, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($search_ref > 0) $sql .=" AND p.rowid=".$search_ref;
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;
if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'";
Expand Down Expand Up @@ -194,7 +217,11 @@
print '<td align="left">';
print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
print '<td align="left">';
print '<input class="flat" type="text" size="6" name="search_company" value="'.$search_company.'">';
print '</td>';
Expand Down
20 changes: 11 additions & 9 deletions htdocs/core/class/extrafields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1422,14 +1422,16 @@ function setOptionalsFromPost($extralabels,&$object,$onlykey='')
return 0;
}
}

/**
* return array_options array for object by extrafields value (using for data send by forms)
*
* @param array $extralabels $array of extrafields
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @return int 1 if array_options set / 0 if no value
* @param array $extralabels $array of extrafields
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @return int 1 if array_options set / 0 if no value
*/
function getOptionalsFromPost($extralabels,$keyprefix='')
function getOptionalsFromPost($extralabels,$keyprefix='',$keysuffix='')
{
global $_POST;

Expand All @@ -1444,24 +1446,24 @@ function getOptionalsFromPost($extralabels,$keyprefix='')
if (in_array($key_type,array('date','datetime')))
{
// Clean parameters
$value_key=dol_mktime($_POST["options_".$key.$keyprefix."hour"], $_POST["options_".$key.$keyprefix."min"], 0, $_POST["options_".$key.$keyprefix."month"], $_POST["options_".$key.$keyprefix."day"], $_POST["options_".$key.$keyprefix."year"]);
$value_key=dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]);
}
else if (in_array($key_type,array('checkbox')))
{
$value_arr=GETPOST("options_".$key.$keyprefix);
$value_arr=GETPOST($keysuffix."options_".$key.$keyprefix);
$value_key=implode($value_arr,',');
}
else if (in_array($key_type,array('price','double')))
{
$value_arr=GETPOST("options_".$key.$keyprefix);
$value_arr=GETPOST($keysuffix."options_".$key.$keyprefix);
$value_key=price2num($value_arr);
}
else
{
$value_key=GETPOST("options_".$key.$keyprefix);
$value_key=GETPOST($keysuffix."options_".$key.$keyprefix);
}

$array_options["options_".$key]=$value_key; // No keyprefix here. keyprefix is used only for read.
$array_options[$keysuffix."options_".$key]=$value_key; // No keyprefix here. keyprefix is used only for read.
}

return $array_options;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4406,7 +4406,7 @@ function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select',
* @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
* @param array $array Array with key+value
* @param string|string[] $id Preselected key or preselected keys for multiselect
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or '&nbsp;').
* @param int $show_empty 0 no empty value allowed, 1 to add an empty value into list (value is '' or '&nbsp;'), <0 to add an empty value with key that is this value.
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key
* @param string $moreparam Add more parameters onto the select tag
Expand Down Expand Up @@ -4455,7 +4455,7 @@ static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_la
{
$textforempty=' ';
if (! empty($conf->use_javascript_ajax)) $textforempty='&nbsp;'; // If we use ajaxcombo, we need &nbsp; here to avoid to have an empty element that is too small.
$out.='<option value="-2"'.($id==-2?' selected':'').'>'.$textforempty.'</option>'."\n"; // id is -2 because -1 is already "do not contact"
$out.='<option value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id==-2?' selected':'').'>'.$textforempty.'</option>'."\n"; // id is -2 because -1 is already "do not contact"
}

if (is_array($array))
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/menus/standard/eldy.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu

if (empty($leftmenu) || ($leftmenu == 'suppliers_bills')) {
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&amp;search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
$newmenu->add("/fourn/facture/impayees.php", $langs->trans("BillShortStatusNotPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&amp;search_status=1", $langs->trans("BillShortStatusNotPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&amp;search_status=2", $langs->trans("BillShortStatusPaid"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_amount_all_tax" value="'.$search_amount_all_tax.'">';
print '</td><td class="liste_titre" align="right">';
$liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid"));
$liststatus=array('fac.fk_statut:0'=>$langs->trans("Draft"),'fac.fk_statut:1,paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid"));
print $form->selectarray('filtre', $liststatus, $filter, 1);
print '</td><td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/compta.lang
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ MenuSpecialExpenses=Special expenses
MenuTaxAndDividends=Taxes and dividends
MenuSalaries=Salaries
MenuSocialContributions=Social/fiscal taxes
MenuNewSocialContribution=New tax payment
MenuNewSocialContribution=New social/fiscal tax
NewSocialContribution=New social/fiscal tax
ContributionsToPay=Social/fiscal taxes to pay
AccountancyTreasuryArea=Accountancy/Treasury area
Expand Down

0 comments on commit 6b85a49

Please sign in to comment.