Merge pull request #8766 from fmarcet/develop
NEW Add Date delivery and Availability on Propals List
This commit is contained in:
commit
ee11a46a66
@ -10,7 +10,7 @@
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2017 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
*
|
||||
@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
$langs->loadLangs(array('companies','propal','compta','bills','orders','products'));
|
||||
$langs->loadLangs(array('companies','propal','compta','bills','orders','products','deliveries'));
|
||||
|
||||
$socid=GETPOST('socid','int');
|
||||
|
||||
@ -76,6 +76,13 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
|
||||
$search_day=GETPOST("search_day","int");
|
||||
$search_month=GETPOST("search_month","int");
|
||||
$search_year=GETPOST("search_year","int");
|
||||
$search_dayfin=GETPOST("search_dayfin","int");
|
||||
$search_monthfin=GETPOST("search_monthfin","int");
|
||||
$search_yearfin=GETPOST("search_yearfin","int");
|
||||
$search_daydelivery=GETPOST("search_daydelivery","int");
|
||||
$search_monthdelivery=GETPOST("search_monthdelivery","int");
|
||||
$search_yeardelivery=GETPOST("search_yeardelivery","int");
|
||||
$search_availability=GETPOST('search_availability','int');
|
||||
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
|
||||
|
||||
$viewstatut=GETPOST('viewstatut','alpha');
|
||||
@ -145,6 +152,8 @@ $arrayfields=array(
|
||||
'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
|
||||
'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
|
||||
'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1),
|
||||
'p.date_livraison'=>array('label'=>$langs->trans("DeliveryDate"), 'checked'=>0),
|
||||
'ava.rowid'=>array('label'=>$langs->trans("AvailabilityPeriod"), 'checked'=>0),
|
||||
'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
|
||||
'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
|
||||
'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
|
||||
@ -202,6 +211,13 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
$search_year='';
|
||||
$search_month='';
|
||||
$search_day='';
|
||||
$search_yearfin='';
|
||||
$search_monthfin='';
|
||||
$search_dayfin='';
|
||||
$search_yeardelivery='';
|
||||
$search_monthdelivery='';
|
||||
$search_daydelivery='';
|
||||
$search_availability='';
|
||||
$viewstatut='';
|
||||
$object_statut='';
|
||||
$toselect='';
|
||||
@ -245,8 +261,9 @@ $sql = 'SELECT';
|
||||
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
|
||||
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
|
||||
$sql.= " typent.code as typent_code,";
|
||||
$sql.= " ava.rowid as availability,";
|
||||
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
|
||||
$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
|
||||
$sql.= ' p.datec as date_creation, p.tms as date_update,';
|
||||
$sql.= " pr.rowid as project_id, pr.ref as project_ref,";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
|
||||
@ -271,6 +288,7 @@ if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'
|
||||
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
|
||||
// We'll need this table joined to the select in order to filter by sale
|
||||
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($search_user > 0)
|
||||
@ -292,6 +310,7 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search
|
||||
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
||||
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
|
||||
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet);
|
||||
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
|
||||
|
||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||
if ($search_login) $sql .= natural_search("u.login", $search_login);
|
||||
@ -323,6 +342,32 @@ else if ($search_year > 0)
|
||||
{
|
||||
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
|
||||
}
|
||||
if ($search_monthfin > 0)
|
||||
{
|
||||
if ($search_yearfin > 0 && empty($search_dayfin))
|
||||
$sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'";
|
||||
else if ($search_yearfin > 0 && ! empty($search_dayfin))
|
||||
$sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'";
|
||||
else
|
||||
$sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'";
|
||||
}
|
||||
else if ($search_yearfin > 0)
|
||||
{
|
||||
$sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,1,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,12,false))."'";
|
||||
}
|
||||
if ($search_monthdelivery > 0)
|
||||
{
|
||||
if ($search_yeardelivery > 0 && empty($search_daydelivery))
|
||||
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,$search_monthdelivery,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,$search_monthdelivery,false))."'";
|
||||
else if ($search_yeardelivery > 0 && ! empty($search_daydelivery))
|
||||
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."'";
|
||||
else
|
||||
$sql.= " AND date_format(p.date_livraison, '%m') = '".$db->escape($search_monthdelivery)."'";
|
||||
}
|
||||
else if ($search_yeardelivery > 0)
|
||||
{
|
||||
$sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,1,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,12,false))."'";
|
||||
}
|
||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale);
|
||||
if ($search_user > 0)
|
||||
{
|
||||
@ -566,7 +611,32 @@ if ($resql)
|
||||
// Date end
|
||||
if (! empty($arrayfields['p.fin_validite']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
//print $langs->trans('Month').': ';
|
||||
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" maxlength="2" name="search_dayfin" value="'.dol_escape_htmltag($search_dayfin).'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_monthfin" value="'.dol_escape_htmltag($search_monthfin).'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$formother->select_year($search_yearfin,'search_yearfin',1, 20, 5);
|
||||
print '</td>';
|
||||
}
|
||||
// Date delivery
|
||||
if (! empty($arrayfields['p.date_livraison']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall" align="center">';
|
||||
//print $langs->trans('Month').': ';
|
||||
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25" type="text" size="1" maxlength="2" name="search_daydelivery" value="'.dol_escape_htmltag($search_daydelivery).'">';
|
||||
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_monthdelivery" value="'.dol_escape_htmltag($search_monthdelivery).'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$formother->select_year($search_yeardelivery,'search_yeardelivery',1, 20, 5);
|
||||
print '</td>';
|
||||
}
|
||||
// Availability
|
||||
if (! empty($arrayfields['ava.rowid']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
|
||||
print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1);
|
||||
print ajax_combobox('search_availability');
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['p.total_ht']['checked']))
|
||||
{
|
||||
@ -644,6 +714,8 @@ if ($resql)
|
||||
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'],$_SERVER["PHP_SELF"],'ddelivery','',$param, 'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'],$_SERVER["PHP_SELF"],'availability','',$param, '',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder);
|
||||
@ -809,6 +881,28 @@ if ($resql)
|
||||
}
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date delivery
|
||||
if (! empty($arrayfields['p.date_livraison']['checked']))
|
||||
{
|
||||
if ($obj->ddelivery)
|
||||
{
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->ddelivery),'day');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Availability
|
||||
if (! empty($arrayfields['ava.rowid']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
$form->form_availability('', $obj->availability, 'none', 1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Amount HT
|
||||
if (! empty($arrayfields['p.total_ht']['checked']))
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -2903,7 +2904,7 @@ class Form
|
||||
|
||||
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
|
||||
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
|
||||
if ($addempty) print '<option value="0"> </option>';
|
||||
foreach($this->cache_availability as $id => $arrayavailability)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user