Example #1
0
/*
 * Actions
 */

// Add new contact
if ($_POST["action"] == 'addcontact' && $user->rights->projet->creer)
{

	$result = 0;
	$project = new Project($db);
	$result = $project->fetch($projectid);

    if ($result > 0 && $projectid > 0)
    {
  		$result = $project->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
    }

	if ($result >= 0)
	{
		Header("Location: contact.php?id=".$project->id);
		exit;
	}
	else
	{
		if ($project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
		{
			$langs->load("errors");
			$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
		}
		else
Example #2
0
// Security check
$socid = 0;
if ($user->societe_id > 0) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'projet', $id);
/*
 * Actions
 */
// Add new contact
if ($action == 'addcontact' && $user->rights->projet->creer) {
    $result = 0;
    $result = $object->fetch($id);
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid') ? 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');
        }
    }
}
// bascule du statut d'un contact
if ($action == 'swapstatut' && $user->rights->projet->creer) {
Example #3
0
        $db->begin();

        $object->ref             = GETPOST('ref','alpha');
        $object->title           = GETPOST('title','alpha');
        $object->socid           = GETPOST('socid','int');
        $object->description     = GETPOST('description','alpha');
        $object->public          = GETPOST('public','alpha');
        $object->datec=dol_now();
        $object->date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int'));
        $object->date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));

        $result = $object->create($user);
        if ($result > 0)
        {
            // Add myself as project leader
            $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal');
            if ($result < 0)
            {
                $langs->load("errors");
                $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
                $error++;
            }
        }
        else
        {
            $langs->load("errors");
            $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
            $error++;
        }

        if (! $error)
Example #4
0
     $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
     if ($result >= 0 || $result == -2) {
         // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
         $sql = 'SELECT ec.rowid FROM ' . MAIN_DB_PREFIX . 'element_contact as ec, ' . MAIN_DB_PREFIX . 'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
         $sql .= ' AND ec.fk_socpeople = ' . $idfortaskuser . " AND ec.element_id = '.{$object->fk_project}.' AND tc.element = 'project' AND source = 'internal'";
         $resql = $db->query($sql);
         if ($resql) {
             $obj = $db->fetch_object($resql);
             if (!$obj) {
                 $project = new Project($db);
                 $project->fetch($object->fk_project);
                 // Get type
                 $listofprojcontact = $project->liste_type_contact('internal');
                 if (count($listofprojcontact)) {
                     $typeforprojectcontact = reset(array_keys($listofprojcontact));
                     $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
                 }
             }
         } else {
             dol_print_error($db);
         }
     }
 }
 if ($result < 0) {
     $error++;
     if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
         $langs->load("errors");
         setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'warnings');
     } else {
         setEventMessages($object->error, $object->errors, 'errors');
     }
 function updateAssociation(&$PDOdb, &$db, &$projectTask)
 {
     // Association des utilisateurs aux tâches du projet
     $TUsers = $this->get_users($PDOdb);
     if (!empty($TUsers)) {
         dol_include_once('/projet/class/project.class.php');
         foreach ($TUsers as $id_user_associated_on_task) {
             $p = new Project($db);
             if ($p->fetch($projectTask->fk_project) > 0) {
                 $p->add_contact($id_user_associated_on_task, 160, 'internal');
                 $projectTask->add_contact($id_user_associated_on_task, 180, 'internal');
             }
         }
     }
 }