* Copyright (C) 2005-2009 Regis Houssin * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ */ /** * \file htdocs/lib/agenda.lib.php * \brief Set of function for the agenda module * \version $Id$ */ /** * Show filter form in agenda view * * @param $canedit * @param $status * @param $year * @param $month * @param $day * @param $showborthday * @param $action * @param $filtera * @param $filtert * @param $filterd * @param $pid * @param $socid */ function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showborthday,$action,$filtera,$filtert,$filterd,$pid,$socid) { global $conf,$langs; // Filters if ($canedit || $conf->projet->enabled) { print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($canedit || $conf->projet->enabled) { print ''; // Buttons print ''; print ''; } print '
'; print ''; if ($canedit) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; } if ($conf->projet->enabled) { print ''; print ''; } print '
'; print $langs->trans("ActionsAskedBy"); print '  '; print $form->select_users($filtera,'userasked',1,'',!$canedit); print '
'; print $langs->trans("or").' '.$langs->trans("ActionsToDoBy"); print '  '; print $form->select_users($filtert,'usertodo',1,'',!$canedit); print '
'; print $langs->trans("or").' '.$langs->trans("ActionsDoneBy"); print '  '; print $form->select_users($filterd,'userdone',1,'',!$canedit); print '
'; print $langs->trans("Project").'   '; print ''; select_projects($socid?$socid:-1,$pid,'projectid'); print '
'; print '
'; print img_picto($langs->trans("ViewCal"),'object_calendar').' '; print '
'; print '
'; print img_picto($langs->trans("ViewList"),'object_list').' '; print '
'; print '

'; } } /** * \brief Show actions to do array * \param max Max nb of records */ function show_array_actions_to_do($max=5) { global $langs, $conf, $user, $db, $bc, $socid; include_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'); include_once(DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'); $sql = "SELECT a.id, a.label, a.datep as dp, a.fk_user_author, a.percent,"; $sql.= " c.code, c.libelle,"; $sql.= " s.nom as sname, s.rowid, s.client"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ", ".MAIN_DB_PREFIX."c_actioncomm as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.id = a.fk_action"; $sql.= " AND a.percent < 100"; $sql.= " AND s.rowid = a.fk_soc"; $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY a.datep DESC, a.id DESC"; $sql.= $db->plimit($max, 0); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; $var = true; $i = 0; $staticaction=new ActionComm($db); $customerstatic=new Client($db); while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print ""; $staticaction->type_code=$obj->code; $staticaction->libelle=$obj->libelle; $staticaction->id=$obj->id; print ''; print ''; $customerstatic->id=$obj->rowid; $customerstatic->nom=$obj->sname; $customerstatic->client=$obj->client; print ''; $datep=$db->jdate($obj->dp); $datep2=$db->jdate($obj->dp2); // Date print '"; // Statut print "\n"; print "\n"; $i++; } print "
'.$langs->trans("LastActionsToDo",$max).''.$langs->trans("FullList").''; print '
'.$staticaction->getNomUrl(1,12).''.dol_trunc($obj->label,22).''.$customerstatic->getNomUrl(1,'',16).''.dol_print_date($datep,'day').' '; $late=0; if ($obj->percent == 0 && $datep && $datep < time()) $late=1; if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late=1; if ($obj->percent > 0 && $obj->percent < 100 && ! $datep2 && $datep && $datep < time()) $late=1; if ($late) print img_warning($langs->trans("Late")); print "".$staticaction->LibStatut($obj->percent,3)."

"; } $db->free($resql); } else { dol_print_error($db); } } /** \brief Show last actions array \param max Max nb of records */ function show_array_last_actions_done($max=5) { global $langs, $conf, $user, $db, $bc, $socid; $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; $sql.= " c.code, c.libelle,"; $sql.= " s.rowid, s.nom as sname, s.client"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ", ".MAIN_DB_PREFIX."c_actioncomm as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.id = a.fk_action"; $sql.= " AND a.percent >= 100"; $sql.= " AND s.rowid = a.fk_soc"; $sql.= " AND s.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql .= " ORDER BY a.datep2 DESC"; $sql .= $db->plimit($max, 0); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); print ''; print ''; print ''; $var = true; $i = 0; $staticaction=new ActionComm($db); $customerstatic=new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print ""; $staticaction->code=$obj->code; $staticaction->libelle=$obj->libelle; $staticaction->id=$obj->id; print ''; print ''; $customerstatic->id=$obj->rowid; $customerstatic->nom=$obj->sname; $customerstatic->client=$obj->client; print ''; // Date print '"; // Statut print "\n"; print "\n"; $i++; } // TODO Ajouter rappel pour "il y a des contrats a mettre en service" // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration" print "
'.$langs->trans("LastDoneTasks",$max).''.$langs->trans("FullList").''; print '
'.$staticaction->getNomUrl(1,12).''.dol_trunc($obj->label,24).''.$customerstatic->getNomUrl(1,'',24).''.dol_print_date($db->jdate($obj->da2),'day'); print "".$staticaction->LibStatut($obj->percent,3)."

"; $db->free($resql); } else { dol_print_error($db); } } /** * Define head array for tabs of agenda setup pages * @return Array of head */ function agenda_prepare_head() { global $langs, $conf, $user; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT."/admin/agenda.php"; $head[$h][1] = $langs->trans("AutoActions"); $head[$h][2] = 'autoactions'; $h++; $head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php"; $head[$h][1] = $langs->trans("Export"); $head[$h][2] = 'xcal'; $h++; return $head; } /** * Define head array for tabs of agenda setup pages * @param action Object action * @return Array of head */ function actions_prepare_head($action) { global $langs, $conf, $user; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$action->id; $head[$h][1] = $langs->trans("CardAction"); $head[$h][2] = 'card'; $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$action->id; $head[$h][1] = $langs->trans('Documents'); $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$action->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; return $head; } ?>