Fix sql
This commit is contained in:
parent
ad57a8480f
commit
5d24aa4830
@ -46,10 +46,6 @@ $show_files=GETPOST('show_files','int');
|
|||||||
$confirm=GETPOST('confirm','alpha');
|
$confirm=GETPOST('confirm','alpha');
|
||||||
$toselect = GETPOST('toselect', 'array');
|
$toselect = GETPOST('toselect', 'array');
|
||||||
|
|
||||||
$dfmonth=GETPOST('dfmonth')?GETPOST('dfmonth'):date("n");
|
|
||||||
$dfyear=GETPOST('dfyear');
|
|
||||||
$filter_op2df=GETPOST('filter_op2df');
|
|
||||||
|
|
||||||
$search_name=GETPOST('search_name');
|
$search_name=GETPOST('search_name');
|
||||||
$search_email=GETPOST('search_email');
|
$search_email=GETPOST('search_email');
|
||||||
$search_town=GETPOST('search_town','alpha');
|
$search_town=GETPOST('search_town','alpha');
|
||||||
@ -66,6 +62,9 @@ $socid=GETPOST('socid');
|
|||||||
$search_user=GETPOST('search_user','int');
|
$search_user=GETPOST('search_user','int');
|
||||||
$search_sale=GETPOST('search_sale','int');
|
$search_sale=GETPOST('search_sale','int');
|
||||||
$search_product_category=GETPOST('search_product_category','int');
|
$search_product_category=GETPOST('search_product_category','int');
|
||||||
|
$search_dfmonth=GETPOST('search_dfmonth','int');
|
||||||
|
$search_dfyear=GETPOST('search_dfyear','int');
|
||||||
|
$search_op2df=GETPOST('search_op2df');
|
||||||
$day=GETPOST("day","int");
|
$day=GETPOST("day","int");
|
||||||
$year=GETPOST("year","int");
|
$year=GETPOST("year","int");
|
||||||
$month=GETPOST("month","int");
|
$month=GETPOST("month","int");
|
||||||
@ -130,7 +129,7 @@ $arrayfields=array(
|
|||||||
'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1),
|
'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1),
|
||||||
'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||||
'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
|
'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
|
||||||
'first_date_fin_validite'=>array('label'=>"1er ".$langs->trans("DateEndPlannedShort"), 'checked'=>1, 'position'=>900),
|
'lower_planned_end_date'=>array('label'=>$langs->trans("LowerDateEndPlannedShort"), 'checked'=>1, 'position'=>900),
|
||||||
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||||
);
|
);
|
||||||
// Extra fields
|
// Extra fields
|
||||||
@ -162,9 +161,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
|||||||
$day='';
|
$day='';
|
||||||
$month='';
|
$month='';
|
||||||
$year='';
|
$year='';
|
||||||
$dfmonth='';
|
$search_dfmonth='';
|
||||||
$dfyear='';
|
$search_dfyear='';
|
||||||
$filter_op2df='';
|
$search_op2df='';
|
||||||
$search_name="";
|
$search_name="";
|
||||||
$search_email="";
|
$search_email="";
|
||||||
$search_town='';
|
$search_town='';
|
||||||
@ -213,7 +212,7 @@ $sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_
|
|||||||
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
|
$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.= " typent.code as typent_code,";
|
||||||
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
||||||
$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as first_date_fin_validite,";
|
$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,";
|
||||||
$sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
|
$sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
|
||||||
$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,';
|
$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,';
|
||||||
$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,';
|
$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,';
|
||||||
@ -287,10 +286,16 @@ $parameters=array();
|
|||||||
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
$sql.=$hookmanager->resPrint;
|
$sql.=$hookmanager->resPrint;
|
||||||
|
|
||||||
|
if ($search_dfyear > 0)
|
||||||
|
{
|
||||||
|
// $sql.= " AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") ".$search_op2df."= '".$db->idate(($search_op2df == "<" ? dol_get_last_day($search_dfyear,$search_dfmonth,false) : dol_get_first_day($search_dfyear,$search_dfmonth,false)))."'";
|
||||||
|
}
|
||||||
|
|
||||||
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
|
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
|
||||||
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
|
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
|
||||||
$sql.= " typent.code,";
|
$sql.= " typent.code,";
|
||||||
$sql.= " state.code_departement, state.nom";
|
$sql.= " state.code_departement, state.nom";
|
||||||
|
//$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").")";
|
||||||
// Add fields from extrafields
|
// Add fields from extrafields
|
||||||
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
|
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
|
||||||
// Add where from hooks
|
// Add where from hooks
|
||||||
@ -298,9 +303,9 @@ $parameters=array();
|
|||||||
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
$sql.=$hookmanager->resPrint;
|
$sql.=$hookmanager->resPrint;
|
||||||
|
|
||||||
if ($dfyear > 0)
|
if ($search_dfyear > 0)
|
||||||
{
|
{
|
||||||
$sql.= " HAVING first_date_fin_validite ".$filter_op2df."= '".$db->idate(($filter_op2df == "<" ? dol_get_last_day($dfyear,$dfmonth,false) : dol_get_first_day($dfyear,$dfmonth,false)))."'";
|
$sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") ".$search_op2df."= '".$db->idate(($search_op2df == "<" ? dol_get_last_day($search_dfyear,$search_dfmonth,false) : dol_get_first_day($search_dfyear,$search_dfmonth,false)))."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= $db->order($sortfield,$sortorder);
|
$sql.= $db->order($sortfield,$sortorder);
|
||||||
@ -345,6 +350,9 @@ if ($resql)
|
|||||||
if ($search_email != '') $param.='&search_email='.urlencode($search_email);
|
if ($search_email != '') $param.='&search_email='.urlencode($search_email);
|
||||||
if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer);
|
if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer);
|
||||||
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
|
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
|
||||||
|
if ($search_op2df != '') $param.='&search_op2df='.urlencode($search_op2df);
|
||||||
|
if ($search_dfyear != '') $param.='&search_dfyear='.urlencode($search_dfyear);
|
||||||
|
if ($search_dfmonth != '') $param.='&search_dfmonth='.urlencode($search_dfmonth);
|
||||||
if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale);
|
if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale);
|
||||||
if ($show_files) $param.='&show_files=' .urlencode($show_files);
|
if ($show_files) $param.='&show_files=' .urlencode($show_files);
|
||||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||||
@ -552,16 +560,16 @@ if ($resql)
|
|||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
// 1er Date de fin
|
// First end date
|
||||||
if (! empty($arrayfields['first_date_fin_validite']['checked']))
|
if (! empty($arrayfields['lower_planned_end_date']['checked']))
|
||||||
{
|
{
|
||||||
print '<td class="liste_titre" align="center">';
|
print '<td class="liste_titre" align="center">';
|
||||||
$arrayofoperators=array('<'=>'<','>'=>'>');
|
$arrayofoperators=array('<'=>'<','>'=>'>');
|
||||||
print $form->selectarray('filter_op2df',$arrayofoperators,$filter_op2df,0);
|
print $form->selectarray('search_op2df',$arrayofoperators,$search_op2df,0);
|
||||||
print '</br>';
|
print '</br>';
|
||||||
print $formother->select_month($dfmonth,'dfmonth');
|
print $formother->select_month($search_dfmonth, 'search_dfmonth', 1);
|
||||||
print ' ';
|
print ' ';
|
||||||
$formother->select_year($dfyear,'dfyear',1, 20, 5);
|
$formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
// Status
|
// Status
|
||||||
@ -608,7 +616,7 @@ if ($resql)
|
|||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||||
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||||
if (! empty($arrayfields['first_date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['first_date_fin_validite']['label'],$_SERVER["PHP_SELF"],"first_date_fin_validite","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
if (! empty($arrayfields['lower_planned_end_date']['checked'])) print_liste_field_titre($arrayfields['lower_planned_end_date']['label'],$_SERVER["PHP_SELF"],"lower_planned_end_date","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||||
if (! empty($arrayfields['status']['checked']))
|
if (! empty($arrayfields['status']['checked']))
|
||||||
{
|
{
|
||||||
print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"');
|
print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"');
|
||||||
@ -797,11 +805,11 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
// Date 1er date fin
|
// Date lower end date
|
||||||
if (! empty($arrayfields['first_date_fin_validite']['checked']))
|
if (! empty($arrayfields['lower_planned_end_date']['checked']))
|
||||||
{
|
{
|
||||||
print '<td align="center" class="nowrap">';
|
print '<td align="center" class="nowrap">';
|
||||||
print dol_print_date($db->jdate($obj->first_date_fin_validite), 'day');
|
print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ AliasNameShort=Alias name
|
|||||||
Companies=Companies
|
Companies=Companies
|
||||||
CountryIsInEEC=Country is inside European Economic Community
|
CountryIsInEEC=Country is inside European Economic Community
|
||||||
ThirdPartyName=Third party name
|
ThirdPartyName=Third party name
|
||||||
|
ThirdPartyEmail=Third party email
|
||||||
ThirdParty=Third party
|
ThirdParty=Third party
|
||||||
ThirdParties=Third parties
|
ThirdParties=Third parties
|
||||||
ThirdPartyProspects=Prospects
|
ThirdPartyProspects=Prospects
|
||||||
|
|||||||
@ -88,7 +88,8 @@ ContactNameAndSignature=For %s, name and signature:
|
|||||||
OnlyLinesWithTypeServiceAreUsed=Only lines with type "Service" will be cloned.
|
OnlyLinesWithTypeServiceAreUsed=Only lines with type "Service" will be cloned.
|
||||||
CloneContract=Clone contract
|
CloneContract=Clone contract
|
||||||
ConfirmCloneContract=Are you sure you want to clone the contract <b>%s</b>?
|
ConfirmCloneContract=Are you sure you want to clone the contract <b>%s</b>?
|
||||||
|
LowerDateEndPlannedShort=Lower planned end date of active services
|
||||||
|
SendContractRef=Contract information __REF__
|
||||||
##### Types de contacts #####
|
##### Types de contacts #####
|
||||||
TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract
|
TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract
|
||||||
TypeContact_contrat_internal_SALESREPFOLL=Sales representative following-up contract
|
TypeContact_contrat_internal_SALESREPFOLL=Sales representative following-up contract
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user