diff --git a/htdocs/comm/action/fiche.php3 b/htdocs/comm/action/fiche.php3 index d58e2af2c7a..36311e9cf3e 100644 --- a/htdocs/comm/action/fiche.php3 +++ b/htdocs/comm/action/fiche.php3 @@ -44,56 +44,59 @@ $db = new Db(); */ if ($action=='add_action') { - $contact = new Contact($db); - $contact->fetch($contactid); + if ($contactid) + { + $contact = new Contact($db); + $contact->fetch($contactid); + } $societe = new Societe($db); $societe->fetch($socid); - $actioncomm = new ActionComm($db); - - $actioncomm->date = $db->idate(mktime($HTTP_POST_VARS["achour"], - $HTTP_POST_VARS["acmin"], - 0, - $HTTP_POST_VARS["acmonth"], - $HTTP_POST_VARS["acday"], - $HTTP_POST_VARS["acyear"]) - ); - if ($actionid == 5) + if ($HTTP_POST_VARS["afaire"] <> 1) { - $actioncomm->percent = 0; + + $actioncomm = new ActionComm($db); + + $actioncomm->date = $db->idate(mktime($HTTP_POST_VARS["achour"], + $HTTP_POST_VARS["acmin"], + 0, + $HTTP_POST_VARS["acmonth"], + $HTTP_POST_VARS["acday"], + $HTTP_POST_VARS["acyear"]) + ); + if ($actionid == 5) + { + $actioncomm->percent = 0; + } + else + { + $actioncomm->percent = 100; + } + $actioncomm->priority = 2; + $actioncomm->type = $actionid; + $actioncomm->contact = $contactid; + + $actioncomm->user = $user; + + $actioncomm->societe = $socid; + $actioncomm->note = $note; + + $actioncomm->add($user); } - else - { - $actioncomm->percent = 100; - } - $actioncomm->priority = 2; - $actioncomm->type = $actionid; - $actioncomm->contact = $contactid; - - $actioncomm->user = $user; - - $actioncomm->societe = $socid; - $actioncomm->note = $note; - - $actioncomm->add($user); if ($todo == 'on' ) { $todo = new ActionComm($db); - $todo->type = 0; - $todo->date = $db->idate(mktime(12,0,0,$remonth, $reday, $reyear)); - - $todo->libelle = $todo_label; + $todo->type = $actionid; + $todo->date = $db->idate(mktime(12,0,0,$remonth, $reday, $reyear)); + $todo->libelle = $todo_label; $todo->priority = 2; - $todo->societe = $societe->id; - $todo->contact = $contactid; - - $todo->user = $user; - - $todo->note = $todo_note; - - $todo->percent = 0; + $todo->societe = $societe->id; + $todo->contact = $contactid; + $todo->user = $user; + $todo->note = $todo_note; + $todo->percent = 0; $todo->add($user); @@ -127,6 +130,14 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] Header("Location: index.php"); } +if ($action=='update') +{ + $action = new Actioncomm($db); + $action->fetch($id); + $action->percent = $HTTP_POST_VARS["percent"]; + $action->contact->id = $HTTP_POST_VARS["scontactid"]; + $action->update(); +} /******************************************************************************/ /* */ @@ -135,21 +146,28 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] /******************************************************************************/ llxHeader(); +$html = new Form($db); /* * * * */ -if ($action=='create' && $actionid && $contactid) { - $caction = new CActioncomm(); - $caction->fetch($db, $actionid); - $contact = new Contact($db); - $contact->fetch($contactid); +if ($action=='create') +{ + $caction = new CActioncomm($db); + + if ($afaire <> 1) + { + $caction->fetch($db, $actionid); + + $contact = new Contact($db); + $contact->fetch($contactid); + } $societe = new Societe($db); $societe->get_nom($socid); - + /* * Rendez-vous * @@ -182,9 +200,7 @@ if ($action=='create' && $actionid && $contactid) { print '