138 |
$this->societe->id = $obj->fk_soc; |
$this->societe->id = $obj->fk_soc; |
139 |
|
|
140 |
$this->db->free($resql); |
$this->db->free($resql); |
141 |
|
|
142 |
|
return 0; |
143 |
|
} |
144 |
|
else |
145 |
|
{ |
146 |
|
return -1; |
147 |
} |
} |
148 |
} |
} |
149 |
else |
else |
150 |
{ |
{ |
151 |
print $this->db->error(); |
print $this->db->error(); |
152 |
|
return -2; |
153 |
} |
} |
154 |
} |
} |
155 |
|
|
328 |
return -1; |
return -1; |
329 |
} |
} |
330 |
} |
} |
331 |
|
|
332 |
|
/* |
333 |
|
* \brief Crée une tache dans le projet |
334 |
|
* \param user Id utilisateur qui crée |
335 |
|
* \param title titre de la tâche |
336 |
|
* \param parent tache parente |
337 |
|
*/ |
338 |
|
function CreateTask($user, $title, $parent = 0) |
339 |
|
{ |
340 |
|
$result = 0; |
341 |
|
if (trim($title)) |
342 |
|
{ |
343 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (fk_projet, title, fk_user_creat) "; |
344 |
|
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.") ;"; |
345 |
|
|
346 |
|
if ($this->db->query($sql) ) |
347 |
|
{ |
348 |
|
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); |
349 |
|
$result = 0; |
350 |
|
} |
351 |
|
else |
352 |
|
{ |
353 |
|
dolibarr_syslog("Project::CreateTask error -2"); |
354 |
|
$this->error=$this->db->error(); |
355 |
|
$result = -2; |
356 |
|
} |
357 |
|
|
358 |
|
if ($result ==0) |
359 |
|
{ |
360 |
|
|
361 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_actors (fk_projet_task, fk_user) "; |
362 |
|
$sql .= " VALUES (".$task_id.",".$user->id.") ;"; |
363 |
|
|
364 |
|
if ($this->db->query($sql) ) |
365 |
|
{ |
366 |
|
$result = 0; |
367 |
|
} |
368 |
|
else |
369 |
|
{ |
370 |
|
dolibarr_syslog("Project::CreateTask error -3"); |
371 |
|
$this->error=$this->db->error(); |
372 |
|
$result = -2; |
373 |
|
} |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
|
} |
378 |
|
else |
379 |
|
{ |
380 |
|
dolibarr_syslog("Project::CreateTask error -1 ref null"); |
381 |
|
$result = -1; |
382 |
|
} |
383 |
|
|
384 |
|
return $result; |
385 |
|
} |
386 |
|
/* |
387 |
|
* \brief Crée une tache dans le projet |
388 |
|
* \param user Id utilisateur qui crée |
389 |
|
* \param title titre de la tâche |
390 |
|
* \param parent tache parente |
391 |
|
*/ |
392 |
|
function TaskAddTime($user, $task, $time) |
393 |
|
{ |
394 |
|
$result = 0; |
395 |
|
|
396 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (fk_task, task_date, task_duration, fk_user)"; |
397 |
|
$sql .= " VALUES (".$this->id.",'$title', ".$user->id.") ;"; |
398 |
|
|
399 |
|
if ($this->db->query($sql) ) |
400 |
|
{ |
401 |
|
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); |
402 |
|
$result = 0; |
403 |
|
} |
404 |
|
else |
405 |
|
{ |
406 |
|
dolibarr_syslog("Project::CreateTask error -2"); |
407 |
|
$this->error=$this->db->error(); |
408 |
|
$result = -2; |
409 |
|
} |
410 |
|
|
411 |
|
if ($result ==0) |
412 |
|
{ |
413 |
|
|
414 |
|
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; |
415 |
|
$sql .= " SET duration_effective = duration_effective + '".ereg_replace(",",".",$time)."'"; |
416 |
|
$sql .= " WHERE rowid = '".$task."';"; |
417 |
|
|
418 |
|
if ($this->db->query($sql) ) |
419 |
|
{ |
420 |
|
$result = 0; |
421 |
|
} |
422 |
|
else |
423 |
|
{ |
424 |
|
dolibarr_syslog("Project::CreateTask error -3"); |
425 |
|
$this->error=$this->db->error(); |
426 |
|
$result = -2; |
427 |
|
} |
428 |
|
} |
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
return $result; |
435 |
|
} |
436 |
} |
} |
437 |
?> |
?> |