fromArray($_POST); if ($act->ag_id == 0) { $act->save(); $ag_id = $act->ag_id; } else { $act->Update(); } $doc_mod=$http->post('doc_mod',"number"); $act->generate_document($doc_mod, $_POST); $sub_action = 'detail'; } /* for delete */ if (isset($_POST['delete']) && $_POST['delete'] == "1") $sub_action = 'delete'; if ($sub_action == "") $sub_action = "list"; // if correction is asked go to directly to add_action if (isset($_POST['corr'])) { $ag_comment = urldecode($_POST['ag_comment']); $sub_action = "add_action"; } // if this page is called from another menu (customer, supplier,...) // a button back is added //---------------------------------------------------------------------- // Update the detail // Add a new action related to this one or update //---------------------------------------------------------------------- if ($sub_action == "update") { // Update the modification if (isset($_POST['save'])) { $act2 = new Follow_Up($cn); $act2->fromArray($_POST); if ($g_user->can_write_action($act2->ag_id) == FALSE ) { echo '
'; echo '

'._('Cette action ne vous est pas autorisée Contactez votre responsable').'

'; echo '
'; return; } $sub_action = "detail"; put_global(array(array('key' => "sa", "value" => "detail"))); try { $act2->verify() ; $act2->Update() ; } catch (Exception $e) { echo ''; echo _("Erreur")." ".$e->getMessage(); echo ''; $sub_action="detail"; $correction = 1; $act = clone $act2; $act->get(); $act->fromArray($_POST); $error_id=$e->getCode(); record_log($e->getTraceAsString()); } } //---------------------------------------------------------------------- // Add a related action //---------------------------------------------------------------------- if (isset($_POST['add_action_here'])) { $ag_id=$http->post('ag_id',"number"); $act = new Follow_Up($cn,$ag_id); if ($g_user->can_write_action($act->ag_id) == FALSE ) { echo '
'; echo '

'._('Cette action ne vous est pas autorisée Contactez votre responsable').'

'; echo '
'; return; } //---------------------------------------- // puis comme ajout normal (copier / coller ) $act->ag_id = 0; $act->d_id = 0; $act->action = $http->post('ag_id',"number"); $act->ag_timestamp=date('d.m.Y'); $act->ag_hour=""; $act->ag_title=""; $act->ag_remind_date=""; echo '
'; // Add hidden tag echo '
'; $act->ag_comment = ""; if (isset($_REQUEST['qcode_dest'])) $act->qcode_dest = $_REQUEST['qcode_dest']; echo $act->Display('NEW', false, $base, $retour); echo ''; echo ''; echo ''; echo '

'; echo $supl_hidden; echo '
'; echo '
'; } } //-------------------------------------------------------------------------------- // Show the detail of an action // permit the update if ($sub_action == 'detail') { echo '
'; if ( $correction == 0 ) { $act = new Follow_Up($cn); $act->ag_id = $ag_id; echo $act->get(); } if ($g_user->can_write_action($ag_id) == true) { echo '
'; echo $supl_hidden; echo HtmlInput::hidden('ac', $_REQUEST['ac']); echo dossier::hidden(); echo $act->Display('UPD', false, $base, $retour); echo ''; echo ''; echo HtmlInput::submit("save", "Sauve",' onclick="$(\'delete\').value=0"'); echo HtmlInput::submit("add_action_here", _("Ajoute un événement à celui-ci"),' onclick="$(\'delete\').value=0"'); echo HtmlInput::submit("delete_bt", _("Efface cet événement "), ' onclick="$(\'delete\').value=1;return confirm_box(\'action_common_frm\',\''. _("Vous confirmez l\'effacement") . '\')" '); echo $retour; echo '
'; } else if ($g_user->can_read_action($ag_id) == true || $act->ag_dest == -1) { echo $act->Display('READ', false, $base, $retour); } else { echo h2info(_("Ce document n'est pas accessible")); return; } echo '
'; } //------------------------------------------------------------------------------- // Delete an action if ($sub_action == 'delete') { // confirmed $cn->start(); $act = new Follow_Up($cn); $act->ag_id = $_REQUEST['ag_id']; $act->get(); if ($g_user->can_write_action($_REQUEST['ag_id'])==true) $act->remove(); $sub_action = "list"; $cn->commit(); Follow_Up::show_action_list($cn, $base); if (isset($act->ag_ref)) echo hb(_('Action ') . $act->ag_ref . _(' effacée')); return; } //-------------------------------------------------------------------------------- // Show a list of the action if ($sub_action == "list") { // Add a button to export to Csv echo '
'; echo HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref", "remind_date","only_internal", "state", "gDossier", "qcode", "start_date", "end_date", "ag_id", "ag_dest_query", "tdoc", "action_query","date_start","date_end","hsstate","searchtag")); echo HtmlInput::hidden("act", "CSV:ActionGestion"); echo HtmlInput::submit("follow_up_csv", "Export CSV",'','smallbutton'); echo "
"; Follow_Up::show_action_list($cn, $base); } //-------------------------------------------------------------------------------- // Save Follow_Up // Stage 2 : Save a NEW action + Files and generate a document //-------------------------------------------------------------------------------- if ($sub_action == "save_action_st2") { $act = new Follow_Up($cn); $act->fromArray($_POST); try { $act->d_id = 0; $act->md_id = (isset($_POST['gen_doc'])) ? $_POST['gen_doc'] : 0; $act->verify(); // insert into action_gestion echo $act->save(); $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get(); echo '

' . hb(_('Evènement Sauvée').' : ' . $act->ag_ref) . '

'; Follow_Up::show_action_list($cn,$base); $url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get(); echo '

' . hb(_('Evènement Sauvée').' : ' . $act->ag_ref) . '

'; } catch (Exception $e) { echo ''; echo _("Erreur")." ".$e->getMessage(); echo ''; $sub_action="add_action"; $error_id=$e->getCode(); record_log($e->getTraceAsString()); } } //-------------------------------------------------------------------------------- // Add an action if ($sub_action == "add_action") { $act = new Follow_Up($cn); $act->fromArray($_POST); $act->ag_id = 0; $act->d_id = 0; echo '
'; // Add hidden tag echo '
'; echo $supl_hidden; echo dossier::hidden(); $act->ag_comment = (isset($_POST['ag_comment'])) ? Decode($_POST['ag_comment']) : ""; if (isset($_REQUEST['qcode'])) $act->qcode_dest = $_REQUEST['qcode']; echo $act->Display('NEW', false, $base, $retour); echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
'; } if ( $error_id != 0 ){ $error[10]='dt_id'; $error[20]='ag_timestamp'; $error[30]='ag_remind_date'; $div=$error[$error_id]; $js=<<$('$div').style.borderColor="red"; $('info_div').innerHTML='erreur'; EOF; echo $js; } ?>