diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index dccf44399e0..0869c3d28ed 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -46,10 +46,6 @@ $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $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_email=GETPOST('search_email'); $search_town=GETPOST('search_town','alpha'); @@ -66,6 +62,9 @@ $socid=GETPOST('socid'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','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"); $year=GETPOST("year","int"); $month=GETPOST("month","int"); @@ -130,7 +129,7 @@ $arrayfields=array( 'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1), 'c.datec'=>array('label'=>$langs->trans("DateCreation"), '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), ); // Extra fields @@ -162,9 +161,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $day=''; $month=''; $year=''; - $dfmonth=''; - $dfyear=''; - $filter_op2df=''; + $search_dfmonth=''; + $search_dfyear=''; + $search_op2df=''; $search_name=""; $search_email=""; $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.= " typent.code as typent_code,"; $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=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,'; @@ -287,10 +286,16 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $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.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom"; +//$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").")"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); // 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 $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); @@ -345,6 +350,9 @@ if ($resql) if ($search_email != '') $param.='&search_email='.urlencode($search_email); 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_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 ($show_files) $param.='&show_files=' .urlencode($show_files); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); @@ -552,16 +560,16 @@ if ($resql) print ''; print ''; } - // 1er Date de fin - if (! empty($arrayfields['first_date_fin_validite']['checked'])) + // First end date + if (! empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; $arrayofoperators=array('<'=>'<','>'=>'>'); - print $form->selectarray('filter_op2df',$arrayofoperators,$filter_op2df,0); + print $form->selectarray('search_op2df',$arrayofoperators,$search_op2df,0); print '
'; - print $formother->select_month($dfmonth,'dfmonth'); + print $formother->select_month($search_dfmonth, 'search_dfmonth', 1); print ' '; - $formother->select_year($dfyear,'dfyear',1, 20, 5); + $formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5); print ''; } // Status @@ -608,7 +616,7 @@ if ($resql) 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.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'])) { print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"'); @@ -797,11 +805,11 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - // Date 1er date fin - if (! empty($arrayfields['first_date_fin_validite']['checked'])) + // Date lower end date + if (! empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; - 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 ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index a7e7c67ae9c..778ac05fdfb 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -29,6 +29,7 @@ AliasNameShort=Alias name Companies=Companies CountryIsInEEC=Country is inside European Economic Community ThirdPartyName=Third party name +ThirdPartyEmail=Third party email ThirdParty=Third party ThirdParties=Third parties ThirdPartyProspects=Prospects diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 63d3c403e50..e0642b27c02 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -88,7 +88,8 @@ ContactNameAndSignature=For %s, name and signature: OnlyLinesWithTypeServiceAreUsed=Only lines with type "Service" will be cloned. CloneContract=Clone contract ConfirmCloneContract=Are you sure you want to clone the contract %s? - +LowerDateEndPlannedShort=Lower planned end date of active services +SendContractRef=Contract information __REF__ ##### Types de contacts ##### TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract TypeContact_contrat_internal_SALESREPFOLL=Sales representative following-up contract