fromArray($_POST);
if ($act->ag_id == 0)
{
$act->save();
$ag_id = $act->ag_id;
}
else
{
$act->Update();
}
$act->generate_document($_POST['doc_mod'], $_POST);
$sub_action = 'detail';
}
/* for delete */
if (isset($_POST['delete']))
$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 '';
exit();
}
$sub_action = "detail";
put_global(array(array('key' => "sa", "value" => "detail")));
$act2->Update() ;
}
//----------------------------------------------------------------------
// Add a related action
//----------------------------------------------------------------------
if (isset($_POST['add_action_here']))
{
$act = new Follow_Up($cn);
//----------------------------------------
// puis comme ajout normal (copier / coller )
$act->fromArray($_POST);
$act->ag_id = 0;
$act->d_id = 0;
$act->action = $_POST['ag_id'];
echo '';
// Add hidden tag
echo '';
echo '
';
}
}
//--------------------------------------------------------------------------------
// Show the detail of an action
// permit the update
if ($sub_action == 'detail')
{
echo '';
$act = new Follow_Up($cn);
$act->ag_id = $ag_id;
echo $act->get();
if ($g_user->can_write_action($ag_id) == true)
{
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"));
exit();
}
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'));
exit();
}
//--------------------------------------------------------------------------------
// Show a list of the action
if ($sub_action == "list")
{
// Add a button to export to Csv
echo '";
Follow_Up::show_action_list($cn, $base);
}
//--------------------------------------------------------------------------------
// 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 '
';
}
//--------------------------------------------------------------------------------
// Save Follow_Up
// Stage 2 : Save the action + Files and generate eventually a document
//--------------------------------------------------------------------------------
if ($sub_action == "save_action_st2")
{
$act = new Follow_Up($cn);
$act->fromArray($_POST);
$act->d_id = 0;
$act->md_id = (isset($_POST['gen_doc'])) ? $_POST['gen_doc'] : 0;
// insert into action_gestion
echo $act->save();
$url = "?$base&sa=detail&ag_id=" . $act->ag_id . '&' . dossier::get();
echo '' . hb('Action 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('Action Sauvée : ' . $act->ag_ref) . '
';
}
?>