diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index fc601cf8a53..39557a6e455 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -32,8 +32,13 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -$langs->load("companies"); -$langs->load("suppliers"); +$langs->loadLangs(array("companies", "suppliers")); + +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); // Security check $id = GETPOST('id','int'); @@ -177,7 +182,7 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria + // Did we click on purge search criteria ? if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter')) // All tests are required to be compatible with all browsers { $sall=""; @@ -198,6 +203,7 @@ if (empty($reshook)) $search_categ=''; $search_categ_thirdparty=''; $search_categ_supplier=''; + $toselect=''; $search_array_options=array(); } @@ -205,7 +211,7 @@ if (empty($reshook)) $objectclass='Contact'; $objectlabel='Contact'; $permtoread = $user->rights->societe->lire; - $permtodelete = $user->rights->societe->delete; + $permtodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -224,7 +230,7 @@ $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql.= " p.rowid as cidp, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,"; +$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields @@ -374,8 +380,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql.= $db->plimit($limit+1, $offset); -//print $sql; -dol_syslog("contact/list.php", LOG_DEBUG); $result = $db->query($sql); if (! $result) { @@ -385,15 +389,18 @@ if (! $result) $num = $db->num_rows($result); +$arrayofselected=is_array($toselect)?$toselect:array(); + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); - $id = $obj->cidp; + $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id); exit; } -llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; +llxHeader('',$title,$help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; @@ -426,16 +433,26 @@ foreach ($search_array_options as $key => $val) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } -print '
'; +// List of mass actions available +$arrayofmassactions = array( +// 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), +); +//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); +if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print ''; if ($optioncss != '') print ''; print ''; print ''; -print ''; print ''; print ''; print ''; +print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit); +print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit); if ($sall) { @@ -447,6 +464,7 @@ if ($search_firstlast_only) print $langs->trans("FilterOnInto", $search_firstlast_only) . $langs->trans("Lastname").", ".$langs->trans("Firstname"); } +$moreforfilter=''; if (! empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; @@ -483,6 +501,7 @@ if ($moreforfilter) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -575,7 +594,18 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { if (! empty($arrayfields["ef.".$key]['checked'])) { - print ''; } } @@ -596,15 +626,17 @@ if (! empty($arrayfields['p.tms']['checked'])) print ''; } +// Status if (! empty($arrayfields['p.statut']['checked'])) { print ''; } +// Action column print ''; print ''; @@ -656,7 +688,7 @@ while ($i < min($num,$limit)) $contactstatic->lastname=$obj->lastname; $contactstatic->firstname=''; - $contactstatic->id=$obj->cidp; + $contactstatic->id=$obj->rowid; $contactstatic->statut=$obj->statut; $contactstatic->poste=$obj->poste; $contactstatic->email=$obj->email; @@ -696,32 +728,32 @@ while ($i < min($num,$limit)) // Phone if (! empty($arrayfields['p.phone']['checked'])) { - print ''; + print ''; } // Phone perso if (! empty($arrayfields['p.phone_perso']['checked'])) { - print ''; + print ''; } // Phone mobile if (! empty($arrayfields['p.phone_mobile']['checked'])) { - print ''; + print ''; } // Fax if (! empty($arrayfields['p.fax']['checked'])) { - print ''; + print ''; } // EMail if (! empty($arrayfields['p.email']['checked'])) { - print ''; + print ''; } // Skype if (! empty($arrayfields['p.skype']['checked'])) { - if (! empty($conf->skype->enabled)) { print ''; } + if (! empty($conf->skype->enabled)) { print ''; } } // Company if (! empty($arrayfields['p.thirdparty']['checked'])) @@ -784,28 +816,35 @@ while ($i < min($num,$limit)) { print ''; } - // Action column - Links Add action and Export vcard - print ''; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; $i++; } +$db->free($result); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + print "
'; + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } print ''; print ''; print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print ''; -print ''; -print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; print '
'.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').''.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').''.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').''.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''.dol_print_phone($obj->fax,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').''.dol_print_phone($obj->fax,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''.dol_print_email($obj->email,$obj->cidp,$obj->socid,'AC_EMAIL',18).''.dol_print_email($obj->email,$obj->rowid,$obj->socid,'AC_EMAIL',18).''.dol_print_skype($obj->skype,$obj->cidp,$obj->socid,'AC_SKYPE',18).''.dol_print_skype($obj->skype,$obj->rowid,$obj->socid,'AC_SKYPE',18).''.$contactstatic->getLibStatut(3).''; - /*print ''.img_object($langs->trans("AddAction"),"action").''; - print '   '; - print ''; - print img_picto($langs->trans("VCard"),'vcard.png').' '; - print ''; */ - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; print "
"; -if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); +//if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); print '
'; -$db->free($result); - llxFooter(); $db->close(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 73f0a815413..e674aea6d5c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -859,7 +859,7 @@ if (! defined('NOLOGIN')) } -dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]); +dol_syslog("--- Access to ".$_SERVER["PHP_SELF"].' - action='.GETPOST('action','az09').', massaction='.GETPOST('massaction','az09')); //Another call for easy debugg //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 40ca07783c4..48e1b67a69c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -187,6 +187,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } +$object = new Societe($db); + /* * Actions @@ -196,7 +198,7 @@ if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -204,7 +206,7 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Do we click on purge search criteria ? + // Did we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_nom=''; @@ -603,7 +605,7 @@ if ($user->rights->societe->client->voir || $socid) $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); $moreforfilter.=''; } -if (! empty($moreforfilter)) +if ($moreforfilter) { print '
'; print $moreforfilter; @@ -905,7 +907,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); } } }