function ordonnanceur_link_event(&$Task)
{
    global $db, $user;
    dol_include_once('/comm/action/class/actioncomm.class.php');
    foreach ($Task['tasks'] as &$task) {
        $t_start = $task['time_estimated_start'];
        $t_end = $task['time_estimated_end'];
        $res = $db->query("SELECT id FROM " . MAIN_DB_PREFIX . "actioncomm WHERE elementtype='project_task' AND fk_element=" . (int) $task['id']);
        $TUserAssigned = array();
        foreach ($task['TUser'] as $idContact => $u) {
            if ($u['selected']) {
                $TUserAssigned[] = array('id' => $idContact);
            }
        }
        if ($obj = $db->fetch_object($res)) {
            $a = new ActionComm($db);
            $a->fetch($obj->id);
            $a->datep = $t_start;
            $a->datef = $t_end;
            $a->durationp = $task['planned_workload'] * 3600;
            $a->label = $task['ref'] . ' ' . $task['label'];
            $a->progress = $task['progress'];
            $a->fk_project = $task['fk_projet'];
            $a->userassigned = $TUserAssigned;
            $a->socid = $task['fk_soc'];
            $a->update($user);
            //  print "update ".$a->id.'<br />';
        } else {
            $a = new ActionComm($db);
            $a->datep = $t_start;
            $a->datef = $t_end;
            $a->userownerid = $user->id;
            $a->type_code = 'AC_OTH_AUTO';
            $a->label = $task['ref'] . ' ' . $task['label'];
            $a->elementtype = 'project_task';
            $a->fk_element = $task['id'];
            $a->fk_project = $task['fk_projet'];
            $a->progress = $task['progress'];
            $a->durationp = $task['planned_workload'] * 3600;
            $a->userassigned = $TUserAssigned;
            $a->socid = $task['fk_soc'];
            $a->add($user);
        }
    }
}
Пример #2
0
    $donotclearsession = 1;
    if ($action == 'add') {
        $action = 'create';
    }
    if ($action == 'update') {
        $action = 'edit';
    }
    $listUserAssignedUpdated = true;
}
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') {
    if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
        setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
    } else {
        if ($id > 0) {
            $object->fetch($id);
            $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid'));
            if ($result > 0) {
                header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
                exit;
            } else {
                setEventMessages($object->error, $object->errors, 'errors');
                $action = '';
            }
        }
    }
}
// Add event
if ($action == 'add') {
    $error = 0;
    if (empty($backtopage)) {
Пример #3
0
    $action = 'show_day';
    $day = $day ? $day : date("d");
}
// View by day
$langs->load("users");
$langs->load("agenda");
$langs->load("other");
$langs->load("commercial");
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('agenda'));
/*
 * Actions
 */
if ($action == 'delete_action') {
    $event = new ActionComm($db);
    $event->fetch($actionid);
    $result = $event->delete();
}
/*
 * View
 */
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&oacute;dulo_Agenda';
llxHeader('', $langs->trans("Agenda"), $help_url);
$form = new Form($db);
$companystatic = new Societe($db);
$now = dol_now();
$nowarray = dol_getdate($now);
$nowyear = $nowarray['year'];
$nowmonth = $nowarray['mon'];
$nowday = $nowarray['mday'];
// Define list of all external calendars (global setup)
/**
 * Create ActionComm
 *
 * @param	array		$authentication		Array of authentication information
 * @param	ActionComm	$actioncomm		    $actioncomm
 * @return	array							Array result
 */
function updateActionComm($authentication, $actioncomm)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateActionComm login="******"Actioncomm id is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        $object = new ActionComm($db);
        $result = $object->fetch($actioncomm['id']);
        if (!empty($object->id)) {
            $objectfound = true;
            $object->datep = $actioncomm['datep'];
            $object->datef = $actioncomm['datef'];
            $object->type_code = $actioncomm['type_code'];
            $object->societe->id = $actioncomm['socid'];
            $object->fk_project = $actioncomm['projectid'];
            $object->note = $actioncomm['note'];
            $object->contact->id = $actioncomm['contactid'];
            $object->usertodo->id = $actioncomm['usertodo'];
            $object->userdone->id = $actioncomm['userdone'];
            $object->label = $actioncomm['label'];
            $object->percentage = $actioncomm['percentage'];
            $object->priority = $actioncomm['priority'];
            $object->fulldayevent = $actioncomm['fulldayevent'];
            $object->location = $actioncomm['location'];
            $object->fk_element = $actioncomm['fk_element'];
            $object->elementtype = $actioncomm['elementtype'];
            //Retreive all extrafield for actioncomm
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                $object->array_options[$key] = $actioncomm[$key];
            }
            $db->begin();
            $result = $object->update($fuser);
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Actioncomm id=' . $actioncomm['id'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Пример #5
0
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
if ($user->societe_id > 0) {
    unset($_GET["action"]);
    $action = '';
}
$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
$object = new ActionComm($db);
if ($id > 0) {
    $ret = $object->fetch($id);
    $object->fetch_thirdparty();
}
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
$objectid = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
if ($user->societe_id > 0) {
    unset($_GET["action"]);
    $action = '';
}
$result = restrictedArea($user, 'agenda', $objectid, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
$object = new ActionComm($db);
if ($objectid > 0) {
    $ret = $object->fetch($objectid);
    if ($ret > 0) {
        $company = new Societe($db);
        $company->fetch($object->societe->id);
        $object->societe = $company;
        // For backward compatibility
        $object->thirdparty = $company;
    }
}
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
Пример #7
0
 /**
  *   Load all objects with filters
  *
  *   @param		DoliDb	$db				Database handler
  *   @param		int		$socid			Filter by thirdparty
  * 	 @param		int		$fk_element		Id of element action is linked to
  *   @param		string	$elementtype	Type of element action is linked to
  *   @param		string	$filter			Other filter
  *   @param		string	$sortfield		Sort on this field
  *   @param		string	$sortorder		ASC or DESC
  *   @return	array or string			Error string if KO, array with actions if OK
  */
 static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = '', $sortorder = '')
 {
     global $conf, $langs;
     $resarray = array();
     $sql = "SELECT a.id";
     $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
     $sql .= " WHERE a.entity IN (" . getEntity('actioncomm', 1) . ")";
     if (!empty($socid)) {
         $sql .= " AND a.fk_soc = " . $socid;
     }
     if (!empty($elementtype)) {
         if ($elementtype == 'project') {
             $sql .= ' AND a.fk_project = ' . $fk_element;
         } else {
             $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'";
         }
     }
     if (!empty($filter)) {
         $sql .= $filter;
     }
     if ($sortorder && $sortfield) {
         $sql .= $db->order($sortfield, $sortorder);
     }
     dol_syslog(get_class() . "::getActions", LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $num = $db->num_rows($resql);
         if ($num) {
             for ($i = 0; $i < $num; $i++) {
                 $obj = $db->fetch_object($resql);
                 $actioncommstatic = new ActionComm($db);
                 $actioncommstatic->fetch($obj->id);
                 $resarray[$i] = $actioncommstatic;
             }
         }
         $db->free($resql);
         return $resarray;
     } else {
         return $db->lasterror();
     }
 }
Пример #8
0
 /**
  *    Load all objects with filters
  *    @param		socid			Filter by thirdparty
  * 	 @param		fk_element		Id of element action is linked to
  *  	 @param		elementtype		Type of element action is linked to
  *    @param		filter			Other filter
  */
 function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '')
 {
     global $conf, $langs;
     $sql = "SELECT a.id";
     $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
     $sql .= " WHERE a.entity = " . $conf->entity;
     if (!empty($socid)) {
         $sql .= " AND a.fk_soc = " . $socid;
     }
     if (!empty($elementtype)) {
         if ($elementtype == 'project') {
             $sql .= ' AND a.fk_project = ' . $fk_element;
         } else {
             $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'";
         }
     }
     if (!empty($filter)) {
         $sql .= $filter;
     }
     dol_syslog("ActionComm::getActions sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->num_rows($resql);
         if ($num) {
             for ($i = 0; $i < $num; $i++) {
                 $obj = $this->db->fetch_object($resql);
                 $actioncommstatic = new ActionComm($this->db);
                 $actioncommstatic->fetch($obj->id);
                 $this->actions[$i] = $actioncommstatic;
             }
         }
         $this->db->free($resql);
         return 1;
     } else {
         $this->error = $this->db->lasterror();
         return -1;
     }
 }
Пример #9
0
/**
 *    	Show html area with actions done
 *
 * 		@param	Conf		$conf		Object conf
 * 		@param	Translate	$langs		Object langs
 * 		@param	DoliDB		$db			Object db
 * 		@param	Adherent|Societe		$object		Object third party or member
 * 		@param	Contact		$objcon		Object contact
 *      @param  int			$noprint    Return string but does not output it
 *      @return	mixed					Return html part or void if noprint is 1
 * TODO change function to be able to list event linked to an object.
 */
function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0)
{
    global $bc, $user, $conf;
    // Check parameters
    if (!is_object($object)) {
        dol_print_error('', 'BadParameter');
    }
    $out = '';
    $histo = array();
    $numaction = 0;
    $now = dol_now('tzuser');
    if (!empty($conf->agenda->enabled)) {
        // Recherche histo sur actioncomm
        $sql = "SELECT a.id, a.label,";
        $sql .= " a.datep as dp,";
        $sql .= " a.datep2 as dp2,";
        $sql .= " a.note, a.percent,";
        $sql .= " a.fk_element, a.elementtype,";
        $sql .= " a.fk_user_author, a.fk_contact,";
        $sql .= " c.code as acode, c.libelle,";
        $sql .= " u.login, u.rowid as user_id";
        if (get_class($object) == 'Societe') {
            $sql .= ", sp.lastname, sp.firstname";
        }
        if (get_class($object) == 'Adherent') {
            $sql .= ", m.lastname, m.firstname";
        }
        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a";
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_actioncomm as c ON a.fk_action = c.id";
        if (get_class($object) == 'Societe') {
            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
        }
        if (get_class($object) == 'Adherent') {
            $sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
        }
        $sql .= " WHERE u.rowid = a.fk_user_author";
        $sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")";
        if (get_class($object) == 'Societe' && $object->id) {
            $sql .= " AND a.fk_soc = " . $object->id;
        }
        if (get_class($object) == 'Adherent') {
            $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
        }
        if (get_class($object) == 'Adherent' && $object->id) {
            $sql .= " AND a.fk_element = " . $object->id;
        }
        if (is_object($objcon) && $objcon->id) {
            $sql .= " AND a.fk_contact = " . $objcon->id;
        }
        $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))";
        $sql .= " ORDER BY a.datep DESC, a.id DESC";
        dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
        $resql = $db->query($sql);
        if ($resql) {
            $i = 0;
            $num = $db->num_rows($resql);
            $var = true;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype);
                $numaction++;
                $i++;
            }
        } else {
            dol_print_error($db);
        }
    }
    if (!empty($conf->mailing->enabled) && !empty($objcon->email)) {
        $langs->load("mails");
        // Recherche histo sur mailing
        $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,";
        $sql .= " 'AC_EMAILING' as acode,";
        $sql .= " u.rowid as user_id, u.login";
        // User that valid action
        $sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u";
        $sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'";
        // Search is done on email.
        $sql .= " AND mc.statut = 1";
        $sql .= " AND u.rowid = m.fk_user_valid";
        $sql .= " AND mc.fk_mailing=m.rowid";
        $sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
        dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
        $resql = $db->query($sql);
        if ($resql) {
            $i = 0;
            $num = $db->num_rows($resql);
            $var = true;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $histo[$numaction] = array('type' => 'mailing', 'id' => $obj->id, 'datestart' => $db->jdate($obj->da), 'dateend' => $db->jdate($obj->da), 'note' => $obj->note, 'percent' => $obj->percentage, 'acode' => $obj->acode, 'userid' => $obj->user_id, 'login' => $obj->login);
                $numaction++;
                $i++;
            }
            $db->free($resql);
        } else {
            dol_print_error($db);
        }
    }
    if (!empty($conf->agenda->enabled) || !empty($conf->mailing->enabled) && !empty($objcon->email)) {
        require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
        require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
        require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
        require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
        $actionstatic = new ActionComm($db);
        $userstatic = new User($db);
        $contactstatic = new Contact($db);
        // TODO uniformize
        $propalstatic = new Propal($db);
        $orderstatic = new Commande($db);
        $facturestatic = new Facture($db);
        $out .= "\n";
        $out .= '<table class="noborder" width="100%">';
        $out .= '<tr class="liste_titre">';
        if ($conf->global->AGENDA_USE_EVENT_TYPE) {
            $out .= '<td colspan="3">';
        } else {
            $out .= '<td colspan="2">';
        }
        if (get_class($object) == 'Societe') {
            $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/listactions.php?socid=' . $object->id . '&amp;status=done">';
        }
        $out .= $langs->trans("ActionsDoneShort");
        if (get_class($object) == 'Societe') {
            $out .= '</a>';
        }
        $out .= '</td>';
        if ($conf->global->AGENDA_USE_EVENT_TYPE) {
            $out .= '<td>';
            $out .= $langs->trans("Type");
            $out .= '</td>';
            $out .= '<td colspan="4" align="right">';
        } else {
            $out .= '<td colspan="5" align="right">';
        }
        $out .= '</td>';
        $out .= '</tr>';
        foreach ($histo as $key => $value) {
            $var = !$var;
            $out .= "<tr " . $bc[$var] . ">";
            $actionstatic->fetch($histo[$key]['id']);
            // Champ date
            $out .= '<td width="120" class="nowrap">';
            $out .= dol_print_date($histo[$key]['datestart'], 'dayhour');
            if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) {
                $tmpa = dol_getdate($histo[$key]['datestart'], true);
                $tmpb = dol_getdate($histo[$key]['dateend'], true);
                if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
                    $out .= '-' . dol_print_date($histo[$key]['dateend'], 'hour');
                } else {
                    $out .= '-' . dol_print_date($histo[$key]['dateend'], 'dayhour');
                }
            }
            $out .= "</td>\n";
            // Picto
            $out .= '<td width="16">&nbsp;</td>';
            // Action
            $out .= '<td>';
            if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
                $actionstatic->type_code = $histo[$key]['acode'];
                $transcode = $langs->trans("Action" . $histo[$key]['acode']);
                $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['libelle'];
                //$actionstatic->libelle=$libelle;
                $actionstatic->libelle = $histo[$key]['note'];
                $actionstatic->id = $histo[$key]['id'];
                $out .= $actionstatic->getNomUrl(1, 120);
            }
            if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
                $out .= '<a href="' . DOL_URL_ROOT . '/comm/mailing/card.php?id=' . $histo[$key]['id'] . '">' . img_object($langs->trans("ShowEMailing"), "email") . ' ';
                $transcode = $langs->trans("Action" . $histo[$key]['acode']);
                $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing';
                $out .= dol_trunc($libelle, 120);
            }
            $out .= '</td>';
            if ($conf->global->AGENDA_USE_EVENT_TYPE) {
                $out .= '<td>';
                $out .= $actionstatic->type;
                $out .= '</td>';
            }
            // Title of event
            //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
            // Objet lie
            // TODO uniformize
            $out .= '<td>';
            //var_dump($histo[$key]['elementtype']);
            if (isset($histo[$key]['elementtype'])) {
                if ($histo[$key]['elementtype'] == 'propal' && !empty($conf->propal->enabled)) {
                    //$propalstatic->ref=$langs->trans("ProposalShort");
                    //$propalstatic->id=$histo[$key]['fk_element'];
                    if ($propalstatic->fetch($histo[$key]['fk_element']) > 0) {
                        $propalstatic->type = $histo[$key]['ftype'];
                        $out .= $propalstatic->getNomUrl(1);
                    } else {
                        $out .= $langs->trans("ProposalDeleted");
                    }
                } elseif (($histo[$key]['elementtype'] == 'order' || $histo[$key]['elementtype'] == 'commande') && !empty($conf->commande->enabled)) {
                    //$orderstatic->ref=$langs->trans("Order");
                    //$orderstatic->id=$histo[$key]['fk_element'];
                    if ($orderstatic->fetch($histo[$key]['fk_element']) > 0) {
                        $orderstatic->type = $histo[$key]['ftype'];
                        $out .= $orderstatic->getNomUrl(1);
                    } else {
                        $out .= $langs->trans("OrderDeleted");
                    }
                } elseif (($histo[$key]['elementtype'] == 'invoice' || $histo[$key]['elementtype'] == 'facture') && !empty($conf->facture->enabled)) {
                    //$facturestatic->ref=$langs->trans("Invoice");
                    //$facturestatic->id=$histo[$key]['fk_element'];
                    if ($facturestatic->fetch($histo[$key]['fk_element']) > 0) {
                        $facturestatic->type = $histo[$key]['ftype'];
                        $out .= $facturestatic->getNomUrl(1, 'compta');
                    } else {
                        $out .= $langs->trans("InvoiceDeleted");
                    }
                } else {
                    $out .= '&nbsp;';
                }
            } else {
                $out .= '&nbsp;';
            }
            $out .= '</td>';
            // Contact pour cette action
            if (!empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
                $contactstatic->lastname = $histo[$key]['lastname'];
                $contactstatic->firstname = $histo[$key]['firstname'];
                $contactstatic->id = $histo[$key]['contact_id'];
                $out .= '<td width="120">' . $contactstatic->getNomUrl(1, '', 10) . '</td>';
            } else {
                $out .= '<td>&nbsp;</td>';
            }
            // Auteur
            $out .= '<td class="nowrap" width="80">';
            //$userstatic->id=$histo[$key]['userid'];
            //$userstatic->login=$histo[$key]['login'];
            //$out.=$userstatic->getLoginUrl(1);
            $userstatic->fetch($histo[$key]['userid']);
            $out .= $userstatic->getNomUrl(1);
            $out .= '</td>';
            // Statut
            $out .= '<td class="nowrap" width="20">' . $actionstatic->LibStatut($histo[$key]['percent'], 3) . '</td>';
            $out .= "</tr>\n";
            $i++;
        }
        $out .= "</table>\n";
        $out .= "<br>\n";
    }
    if ($noprint) {
        return $out;
    } else {
        print $out;
    }
}
Пример #10
0
{
  $action = '';
  $socid = $user->societe_id;
}



/*
 * View
 */

$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);

$act = new ActionComm($db);
$act->fetch($_GET["id"]);
$act->info($_GET["id"]);

$head=actions_prepare_head($act);
dol_fiche_head($head, 'info', $langs->trans("Action"),0,'action');


print '<table width="100%"><tr><td>';
dol_print_object_info($act);
print '</td></tr></table>';

print '</div>';

$db->close();

llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.20 $');
Пример #11
0
 */
if ($_GET["action"] == 'delete') {
    $upload_dir = $conf->agenda->dir_output . '/' . dol_sanitizeFileName($objectid);
    $file = $upload_dir . '/' . $_GET['urlfile'];
    // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
    dol_delete_file($file);
}
/*
 * View
 */
$form = new Form($db);
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('', $langs->trans("Agenda"), $help_url);
if ($objectid > 0) {
    $act = new ActionComm($db);
    if ($act->fetch($objectid)) {
        $upload_dir = $conf->agenda->dir_output . '/' . dol_sanitizeFileName($objectid);
        $company = new Societe($db);
        $company->fetch($act->societe->id);
        $act->societe = $company;
        $author = new User($db);
        $author->fetch($act->author->id);
        $act->author = $author;
        if ($act->contact->id) {
            $act->fetch_contact($act->contact->id);
        }
        $head = actions_prepare_head($act);
        dol_fiche_head($head, 'documents', $langs->trans("Action"), 0, 'action');
        // Affichage fiche action en mode visu
        print '<table class="border" width="100%"';
        // Ref
Пример #12
0
}

// View or edit
if ($id)
{
	if ($error)
	{
		print '<div class="error">'.$error.'</div><br>';
	}
	if ($mesg)
	{
		print $mesg.'<br>';
	}

	$act = new ActionComm($db);
	$result=$act->fetch($id);
	if ($result < 0)
	{
		dol_print_error($db,$act->error);
		exit;
	}

	$societe = new Societe($db);
	if ($act->societe->id)
	{
		$result=$societe->fetch($act->societe->id);
	}
	$act->societe = $societe;

	if ($act->author->id > 0)   { $tmpuser=new User($db); $res=$tmpuser->fetch($act->author->id); $act->author=$tmpuser; }
	if ($act->usermod->id > 0)  { $tmpuser=new User($db); $res=$tmpuser->fetch($act->usermod->id); $act->usermod=$tmpuser; }
function _events($date_start, $date_end)
{
    global $db, $conf, $langs, $user, $hookmanager;
    $hookmanager->initHooks(array('agenda'));
    $pid = GETPOST("projectid", "int", 3);
    $status = GETPOST("status");
    $type = GETPOST("type");
    $state_id = GETPOST('state_id');
    $maxprint = GETPOST("maxprint") ? GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW;
    //First try with GETPOST(array) (I don't know when it can be an array but why not)
    $actioncode = GETPOST("actioncode", "array", 3) ? GETPOST("actioncode", "array", 3) : (GETPOST("actioncode") == '0' ? '0' : '');
    //If empty then try GETPOST(alpha) (this one works with comm/action/index.php
    if (empty($actioncode)) {
        $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : '');
        if (!empty($actioncode)) {
            $actioncode = array($actioncode);
        }
    }
    if (empty($actioncode)) {
        $actioncode = array();
    }
    $filter = GETPOST("filter", '', 3);
    $filtert = GETPOST("usertodo", "int", 3) ? GETPOST("usertodo", "int", 3) : GETPOST("filtert", "int", 3);
    $usergroup = GETPOST("usergroup", "int", 3);
    $showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1;
    if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
        $filtert = $user->id;
    }
    $socid = GETPOST("socid", "int");
    $t_start = strtotime($date_start);
    $t_end = strtotime($date_end);
    $now = dol_now();
    $sql = 'SELECT ';
    if ($usergroup > 0) {
        $sql .= " DISTINCT";
    }
    $sql .= ' a.id, a.label,';
    $sql .= ' a.datep,';
    $sql .= ' a.datep2,';
    $sql .= ' a.percent,';
    $sql .= ' a.fk_user_author,a.fk_user_action,';
    $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
    $sql .= ' a.fk_soc, a.fk_contact,u.color,a.note,';
    $sql .= ' ca.code as type_code, ca.libelle as type_label';
    $sql .= ' FROM ' . MAIN_DB_PREFIX . "actioncomm as a";
    $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_actioncomm as ca ON (a.fk_action = ca.id)';
    $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user u ON (a.fk_user_action=u.rowid )';
    if (!empty($conf->global->FULLCALENDAR_FILTER_ON_STATE) && !empty($state_id)) {
        $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe s ON (s.rowid = a.fk_soc)';
        $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople sp ON (sp.rowid = a.fk_contact)';
    }
    if (!$user->rights->societe->client->voir && !$socid) {
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
    }
    // We must filter on assignement table
    if ($filtert > 0 || $usergroup > 0) {
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_resources as ar ON (ar.fk_actioncomm = a.id)";
    }
    if ($usergroup > 0) {
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
    }
    $sql .= ' WHERE 1=1';
    $sql .= ' AND a.entity IN (' . getEntity('agenda', 1) . ')';
    if ($actioncode) {
        $sql .= " AND ca.code IN ('" . implode("','", $actioncode) . "')";
    }
    if ($conf->global->DONT_SHOW_AUTO_EVENT && strpos(implode(',', $actioncode), 'AC_OTH_AUTO') == false) {
        $sql .= " AND ca.code != 'AC_OTH_AUTO'";
    }
    if ($pid) {
        $sql .= " AND a.fk_project=" . $db->escape($pid);
    }
    if (!$user->rights->societe->client->voir && !$socid) {
        $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = "******")";
    }
    if ($socid > 0) {
        $sql .= ' AND a.fk_soc = ' . $socid;
    }
    if (!empty($conf->global->FULLCALENDAR_FILTER_ON_STATE) && !empty($state_id)) {
        $sql .= ' AND (s.fk_departement = ' . $state_id . ' OR sp.fk_departement = ' . $state_id . ')';
    }
    // We must filter on assignement table
    if ($filtert > 0 || $usergroup > 0) {
        $sql .= " AND ar.element_type='user'";
    }
    $sql .= " AND\n\t\t\t(\n\t\t\t\t(a.datep2>='" . $db->idate($t_start - 60 * 60 * 24 * 7) . "' AND datep<='" . $db->idate($t_end + 60 * 60 * 24 * 10) . "')\n\t\t\t\tOR\n\t\t\t  \t(a.datep BETWEEN '" . $db->idate($t_start - 60 * 60 * 24 * 7) . "' AND '" . $db->idate($t_end + 60 * 60 * 24 * 10) . "')\n\t\t\t) ";
    if ($type) {
        $sql .= " AND ca.id = " . $type;
    }
    if ($status == '0') {
        $sql .= " AND a.percent = 0";
    }
    if ($status == '-1') {
        $sql .= " AND a.percent = -1";
    }
    // Not applicable
    if ($status == '50') {
        $sql .= " AND (a.percent > 0 AND a.percent < 100)";
    }
    // Running already started
    if ($status == 'done' || $status == '100') {
        $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '" . $db->idate($now) . "'))";
    }
    if ($status == 'todo') {
        $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '" . $db->idate($now) . "'))";
    }
    // We must filter on assignement table
    if ($filtert > 0 || $usergroup > 0) {
        $sql .= " AND (";
        if ($filtert > 0) {
            $sql .= "ar.fk_element = " . $filtert;
        }
        if ($usergroup > 0) {
            $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
        }
        $sql .= ")";
    }
    // Sort on date
    $sql .= ' ORDER BY datep';
    $TEvent = array();
    if (isset($_REQUEST['DEBUG'])) {
        print $sql;
    }
    $res = $db->query($sql);
    //var_dump($db);
    $TSociete = array();
    $TContact = array();
    $TUser = array();
    $TProject = array();
    $TEventObject = array();
    while ($obj = $db->fetch_object($res)) {
        $event = new ActionComm($db);
        $event->fetch($obj->id);
        $event->fetch_userassigned();
        $event->color = $obj->color;
        $TEventObject[] = $event;
    }
    foreach ($TEventObject as &$event) {
        if ($event->socid > 0 && !isset($TSociete[$event->socid])) {
            $societe = new Societe($db);
            $societe->fetch($event->socid);
            $TSociete[$event->socid] = $societe->getNomUrl(1);
        }
        if ($event->contactid > 0 && !isset($TContact[$event->contactid])) {
            $contact = new Contact($db);
            $contact->fetch($event->contactid);
            $TContact[$event->contactid] = $contact->getNomUrl(1);
        }
        $TUserassigned = array();
        $TColor = array();
        if ($event->color && empty($conf->global->FULLCALENDAR_USE_ASSIGNED_COLOR)) {
            $TColor[] = '#' . $event->color;
        }
        if (!empty($conf->global->FULLCALENDAR_SHOW_AFFECTED_USER)) {
            $userownerid = (int) $event->userownerid;
            if ($userownerid > 0 && !isset($TUser[$userownerid])) {
                $u = new User($db);
                $u->fetch($userownerid);
                $TUser[$userownerid] = $u;
            }
            $TUserassigned[$userownerid] = $TUser[$userownerid]->getNomUrl(1);
        }
        if (!empty($conf->global->FULLCALENDAR_SHOW_PROJECT) && $event->fk_project > 0 && !isset($TProject[$event->fk_project])) {
            $p = new Project($db);
            $p->fetch($event->fk_project);
            $TProject[$event->fk_project] = $p->getNomUrl(1);
        }
        if (!empty($conf->global->FULLCALENDAR_SHOW_AFFECTED_USER) && !empty($event->userassigned)) {
            foreach ($event->userassigned as &$ua) {
                $userid = (int) $ua['id'];
                if (!isset($TUser[$userid])) {
                    $u = new User($db);
                    $u->fetch($userid);
                    $TUser[$userid] = $u;
                }
                if (!isset($TUserassigned[$userid])) {
                    $TUserassigned[] = $TUser[$userid]->getNomUrl(1);
                }
                if ($TUser[$userid]->color && !in_array('#' . $TUser[$userid]->color, $TColor)) {
                    $TColor[] = '#' . $TUser[$userid]->color;
                }
            }
        }
        $editable = false;
        if ($user->id == $event->userownerid || $user->rights->agenda->allactions->create) {
            $editable = true;
        }
        //background: linear-gradient(to bottom, #1e5799 0%,#2989d8 25%,#207cca 67%,#7db9e8 100%);
        //$colors = implode(',',$TColor);
        $colors = '';
        $color = '';
        if (!empty($TColor)) {
            $color = $TColor[0];
            if (!empty($conf->global->FULLCALENDAR_SHOW_ALL_ASSIGNED_COLOR) && count($TColor) > 1) {
                $colors = 'linear-gradient(to right ';
                foreach ($TColor as $c) {
                    $colors .= ',' . $c;
                }
                $colors .= ')';
            }
        }
        $TEvent[] = array('id' => $event->id, 'title' => $event->label, 'allDay' => (bool) $event->fulldayevent, 'start' => empty($event->datep) ? '' : date('Y-m-d H:i:s', (int) $event->datep), 'end' => empty($event->datef) ? '' : date('Y-m-d H:i:s', (int) $event->datef), 'url' => dol_buildpath('/comm/action/card.php?id=' . $event->id, 1), 'editable' => $editable, 'color' => $color, 'isDarkColor' => isDarkColor($color), 'colors' => $colors, 'note' => $event->note, 'statut' => $event->getLibStatut(3), 'fk_soc' => $event->socid, 'fk_contact' => $event->contactid, 'fk_user' => $event->userownerid, 'fk_project' => $event->fk_project, 'societe' => !empty($TSociete[$event->socid]) ? $TSociete[$event->socid] : '', 'contact' => !empty($TContact[$event->contactid]) ? $TContact[$event->contactid] : '', 'user' => !empty($TUserassigned) ? implode(', ', $TUserassigned) : '', 'project' => !empty($TProject[$event->fk_project]) ? $TProject[$event->fk_project] : '', 'more' => '');
    }
    $use_workstation_color = null;
    if (GETPOST('use_workstation_color')) {
        $use_workstation_color = 1;
    }
    //TODO getCalendarEvents compatbile standard
    // Complete $eventarray with events coming from external module
    $parameters = array('use_workstation_color' => $use_workstation_color, 'sql' => $sql);
    $action = 'getEvents';
    $reshook = $hookmanager->executeHooks('updateFullcalendarEvents', $parameters, $TEvent, $action);
    if (!empty($hookmanager->resArray['eventarray'])) {
        $TEvent = array_merge($TEvent, $hookmanager->resArray['eventarray']);
    }
    return $TEvent;
}
Пример #14
0
$socid = GETPOST('socid', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
if ($user->societe_id > 0) {
    unset($_GET["action"]);
    $action = '';
}
$result = restrictedArea($user, 'agenda', $objectid, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
$object = new ActionComm($db);
/*
 * Actions
 */
// Add new contact
if ($action == 'addcontact' && $user->rights->action->creer) {
    $result = $object->fetch($id);
    if ($object->id > 0) {
        $contactid = GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int');
        $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
    }
    if ($result >= 0) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
        exit;
    } else {
        if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            $langs->load("errors");
            setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
        } else {
            setEventMessage($object->error, 'errors');
        }
    }
Пример #15
0
 */
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
$langs->load("commercial");
$id = GETPOST('id', 'int');
// Security check
if ($user->societe_id > 0) {
    $action = '';
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
/*
 * View
 */
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('', $langs->trans("Agenda"), $help_url);
$act = new ActionComm($db);
$act->fetch($id);
$act->info($act->id);
$head = actions_prepare_head($act);
dol_fiche_head($head, 'info', $langs->trans("Action"), 0, 'action');
print '<table width="100%"><tr><td>';
dol_print_object_info($act);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();