diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 27515db3c68..da8a9995538 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -141,22 +141,23 @@ $parameters=array(); $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'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -// Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers -{ - $search_field1=''; - $search_field2=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=''; - $search_array_options=array(); -} - - if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // 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_field1=''; + $search_field2=''; + $search_date_creation=''; + $search_date_update=''; + $toselect=''; + $search_array_options=array(); + } + + // Mass actions $objectclass='Skeleton'; $objectlabel='Skeleton'; $permtoread = $user->rights->skeleton->read; @@ -180,7 +181,6 @@ $form=new Form($db); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; $help_url=''; $title = $langs->trans('MyModuleListTitle'); -llxHeader('', $title, $help_url); // Put here content of your page @@ -250,298 +250,306 @@ $sql.= $db->plimit($limit+1, $offset); dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); -if ($resql) +if (! $resql) { - $num = $db->num_rows($resql); - - $arrayofselected=is_array($toselect)?$toselect:array(); - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); - if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id); + exit; +} + +llxHeader('', $title, $help_url); + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); +if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); +if ($optioncss != '') $param.='&optioncss='.$optioncss; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +$arrayofmassactions = array( + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'."\n"; + + +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) +{ + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->facture->lire; + $delallowed=$user->rights->facture->lire; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { - $error++; - dol_print_error($db); + print '| '; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.firstname']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.poste']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.zip']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.town']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.phone']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.phone_perso']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.phone_mobile']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.fax']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.email']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.skype']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.thirdparty']['checked'])) +{ + print ''; + print ''; + print ' | '; +} +if (! empty($arrayfields['p.priv']['checked'])) +{ + print ''; + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('search_priv',$selectarray,$search_priv,1); + print ' | '; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print ''; + print ' | '; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['p.datec']['checked'])) +{ + print ''; + print ' | '; +} +// Date modification +if (! empty($arrayfields['p.tms']['checked'])) +{ + print ''; + print ' | '; +} +if (! empty($arrayfields['p.statut']['checked'])) +{ + print ''; + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print ' | '; +} +print ''; +print ''; +print ''; +print ' | '; + +print '|||||||||||||||||
| '; - print ''; - print ' | '; + print ''; + print $contactstatic->getNomUrl(1,'',0); + print ' | '; } + // Firstname if (! empty($arrayfields['p.firstname']['checked'])) { - print ''; - print ''; - print ' | '; - } - if (! empty($arrayfields['p.poste']['checked'])) - { - print ''; - print ''; - print ' | '; + print ''.$obj->firstname.' | '; } + // Zip if (! empty($arrayfields['p.zip']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.$obj->zip.' | '; } + // Town if (! empty($arrayfields['p.town']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.$obj->town.' | '; } - if (! empty($arrayfields['p.phone']['checked'])) + // Function + if (! empty($arrayfields['p.poste']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.dol_trunc($obj->poste,20).' | '; } - if (! empty($arrayfields['p.phone_perso']['checked'])) + // Phone + if (! empty($arrayfields['p.phone']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; } + // Phone perso + if (! empty($arrayfields['p.phone_perso']['checked'])) + { + print ''.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; + } + // Phone mobile if (! empty($arrayfields['p.phone_mobile']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; } + // Fax if (! empty($arrayfields['p.fax']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.dol_print_phone($obj->fax,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; } + // EMail if (! empty($arrayfields['p.email']['checked'])) { - print ''; - print ''; - print ' | '; + print ''.dol_print_email($obj->email,$obj->cidp,$obj->socid,'AC_EMAIL',18).' | '; } + // Skype if (! empty($arrayfields['p.skype']['checked'])) { - print ''; - print ''; - print ' | '; + if (! empty($conf->skype->enabled)) { print ''.dol_print_skype($obj->skype,$obj->cidp,$obj->socid,'AC_SKYPE',18).' | '; } } + // Company if (! empty($arrayfields['p.thirdparty']['checked'])) { - print ''; - print ''; + print ' | '; + if ($obj->socid) + { + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); + } + else + print ' '; print ' | '; } + + // Private/Public if (! empty($arrayfields['p.priv']['checked'])) { - print ''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('search_priv',$selectarray,$search_priv,1); - print ' | '; + print ''.$contactstatic->LibPubPriv($obj->priv).' | '; } + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -587,203 +749,58 @@ if ($result) { if (! empty($arrayfields["ef.".$key]['checked'])) { - print ''; + print ' | getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ' | '; } } } // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['p.datec']['checked'])) { - print ''; + print ' | '; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ' | '; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) { - print ''; + print ' | '; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ' | '; } + // Status if (! empty($arrayfields['p.statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); - print ' | '; + print ''.$contactstatic->getLibStatut(3).' | '; } - print ''; - print ''; - print ''; - print ' | '; - - print ''; + print ''.img_object($langs->trans("AddAction"),"action").''; + print ' '; + print ''; + print img_picto($langs->trans("VCard"),'vcard.png').' '; + print ' | '; - $var=True; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($result); - - $var=!$var; - print "
| '; - print $contactstatic->getNomUrl(1,'',0); - print ' | '; - } - // Firstname - if (! empty($arrayfields['p.firstname']['checked'])) - { - print ''.$obj->firstname.' | '; - } - // Zip - if (! empty($arrayfields['p.zip']['checked'])) - { - print ''.$obj->zip.' | '; - } - // Town - if (! empty($arrayfields['p.town']['checked'])) - { - print ''.$obj->town.' | '; - } - // Function - if (! empty($arrayfields['p.poste']['checked'])) - { - print ''.dol_trunc($obj->poste,20).' | '; - } - // Phone - if (! empty($arrayfields['p.phone']['checked'])) - { - print ''.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; - } - // Phone perso - if (! empty($arrayfields['p.phone_perso']['checked'])) - { - print ''.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; - } - // Phone mobile - if (! empty($arrayfields['p.phone_mobile']['checked'])) - { - print ''.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; - } - // Fax - if (! empty($arrayfields['p.fax']['checked'])) - { - print ''.dol_print_phone($obj->fax,$obj->country_code,$obj->cidp,$obj->socid,'AC_TEL').' | '; - } - // EMail - if (! empty($arrayfields['p.email']['checked'])) - { - print ''.dol_print_email($obj->email,$obj->cidp,$obj->socid,'AC_EMAIL',18).' | '; - } - // Skype - if (! empty($arrayfields['p.skype']['checked'])) - { - if (! empty($conf->skype->enabled)) { print ''.dol_print_skype($obj->skype,$obj->cidp,$obj->socid,'AC_SKYPE',18).' | '; } - } - // Company - if (! empty($arrayfields['p.thirdparty']['checked'])) - { - print ''; - if ($obj->socid) - { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); - } - else - print ' '; - print ' | '; - } - - // Private/Public - if (! empty($arrayfields['p.priv']['checked'])) - { - print ''.$contactstatic->LibPubPriv($obj->priv).' | '; - } - - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ' | '; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ' | '; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ' | '; - } - // Status - if (! empty($arrayfields['p.statut']['checked'])) - { - print ''.$contactstatic->getLibStatut(3).' | '; - } - // Action column - Links Add action and Export vcard - print ''; - print ''.img_object($langs->trans("AddAction"),"action").''; - print ' '; - print ''; - print img_picto($langs->trans("VCard"),'vcard.png').' '; - print ' | '; - - print "