Merge pull request #5811 from aspangaro/5.0-p19

New: Add type invoice in customer search list
This commit is contained in:
Laurent Destailleur
2016-09-29 10:24:42 +02:00
committed by GitHub
2 changed files with 47 additions and 17 deletions

View File

@@ -2884,8 +2884,7 @@ else if ($id > 0 || ! empty($ref))
// Invoice content
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1);

View File

@@ -70,6 +70,7 @@ $userid=GETPOST('userid','int');
$search_product_category=GETPOST('search_product_category','int');
$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha');
$search_refcustomer=GETPOST('search_refcustomer','alpha');
$search_type=GETPOST('search_type','int');
$search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_montant_vat=GETPOST('search_montant_vat','alpha');
@@ -142,6 +143,7 @@ $checkedtypetiers=0;
$arrayfields=array(
'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0),
'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1),
'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
@@ -191,6 +193,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS
$search_product_category='';
$search_ref='';
$search_refcustomer='';
$search_type='';
$search_project='';
$search_societe='';
$search_montant_ht='';
@@ -295,6 +298,15 @@ if ($filtre)
}
if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
if ($search_type != '' && $search_type >= 0)
{
if ($search_type == '0') $sql.=" AND f.type = 0"; // standard
if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement
if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note
if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit
if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
}
if ($search_project) $sql .= natural_search('p.ref', $search_project);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_town) $sql.= natural_search('s.town', $search_town);
@@ -310,7 +322,7 @@ if ($search_status != '' && $search_status >= 0)
{
if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft
if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed
if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some correupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned
}
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode."";
@@ -400,7 +412,7 @@ if ($resql)
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
if ($socid)
{
$soc = new Societe($db);
@@ -419,6 +431,7 @@ if ($resql)
if ($year_lim) $param.='&year_lim=' .urlencode($year_lim);
if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer);
if ($search_type != '') $param.='&search_type='.urlencode($search_type);
if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale);
if ($search_user > 0) $param.='&search_user=' .urlencode($search_user);
@@ -438,7 +451,7 @@ if ($resql)
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$arrayofmassactions=array(
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge")
@@ -457,7 +470,7 @@ if ($resql)
}
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$i = 0;
print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -467,7 +480,7 @@ if ($resql)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);
if ($massaction == 'presend')
@@ -496,7 +509,7 @@ if ($resql)
print '<input type="hidden" name="massaction" value="confirm_presend">';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail = new FormMail($db);
dol_fiche_head(null, '', '');
@@ -615,12 +628,13 @@ if ($resql)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.facnumber']['checked'])) print_liste_field_titre($arrayfields['f.facnumber']['label'],$_SERVER['PHP_SELF'],'f.facnumber','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'],$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'],$_SERVER["PHP_SELF"],'f.type','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'],$_SERVER['PHP_SELF'],'f.datef','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder);
@@ -673,6 +687,14 @@ if ($resql)
print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
print '</td>';
}
// Type
if (! empty($arrayfields['f.type']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="right">';
$listtype=array('0'=>$langs->trans("InvoiceStandard"), '1'=>$langs->trans("InvoiceReplacement"), '2'=>$langs->trans("InvoiceAvoir"), '3'=>$langs->trans("InvoiceDeposit"), '4'=>$langs->trans("InvoiceProForma"), '5'=>$langs->trans("InvoiceDeposit"));
print $form->selectarray('search_type', $listtype, $search_type, 1);
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date']['checked']))
{
@@ -865,7 +887,7 @@ if ($resql)
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Customer ref
if (! empty($arrayfields['f.ref_client']['checked']))
{
@@ -874,7 +896,16 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Type
if (! empty($arrayfields['f.type']['checked']))
{
print '<td class="nowrap">';
print $object->getLibType($obj->type);
print "</td>";
if (! $i) $totalarray['nbfield']++;
}
// Date
if (! empty($arrayfields['f.date']['checked']))
{
@@ -883,7 +914,7 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date limit
if (! empty($arrayfields['f.date_lim_reglement']['checked']))
{
@@ -895,7 +926,7 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Third party
if (! empty($arrayfields['s.nom']['checked']))
{
@@ -949,7 +980,7 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
@@ -958,7 +989,7 @@ if ($resql)
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Amount HT
if (! empty($arrayfields['f.total_ht']['checked']))
{
@@ -999,7 +1030,7 @@ if ($resql)
if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
$totalarray['totalrtp'] += $remaintopay;
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{