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 ); $sub_action="detail"; if ( $_POST["new_ref"] != "0") { $act2->add_depend($_POST['new_ref']); } if ( isset ($_POST['sup_dep'])) { $act2->suppress_depend($_POST['sup_dep']); } $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->ag_ref_ag_id=$_POST['ag_id']; echo '
'; // Add hidden tag echo '
'; echo dossier::hidden(); $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 '
'; $act=new Follow_Up($cn); $act->ag_id=$ag_id; $act->suppress=1; echo $act->get(); $act->ag_comment=Decode($act->ag_comment); echo '
'; echo $supl_hidden; echo HtmlInput::hidden('ac',$_REQUEST['ac']); echo dossier::hidden(); echo $act->Display('UPD',false,$base,$retour); echo ''; echo HtmlInput::submit("save","Sauve"); echo HtmlInput::submit("add_action_here",_("Ajoute une action à celle-ci")); echo HtmlInput::submit("delete",_("Efface cette action"),' onclick="return confirm(\''._("Vous confirmez l\'effacement").'\')" '); echo $retour; echo '
'; echo '
'; } //------------------------------------------------------------------------------- // Delete an action if ( $sub_action == 'delete' ) { // confirmed $cn->start(); $act=new Follow_Up($cn); $act->ag_id=$_REQUEST['ag_id']; $act->get(); $act->remove(); $sub_action="list"; $cn->commit(); ShowActionList($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" ) { ShowActionList($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 $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 '
'; } //-------------------------------------------------------------------------------- // 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->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_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).'

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

'.hb('Action Sauvée : '.$act->ag_ref).'

'; } //--------------------------------------------------------------------- function ShowActionList($cn,$p_base) { // show the search menu ?>
">
get_by_qcode($_REQUEST['qcode']); // if quick code not found then nothing if ( $fiche->id == 0 ) $str=' and false '; else $str=" and (f_id_dest= ".$fiche->id." ) "; } } if (isset($_GET['tdoc']) && $_GET['tdoc'] != -1 ) { $query .= ' and dt_id = '.Formatstring($_GET['tdoc']); } if ( ! $see_all->selected ) $query .= ' and ag_state in (2,3) '; if ( ! $my_action->selected ) { $query .=" and (ag_owner='".$_SESSION['g_user']."' or ag_dest in (select p_id from profile_user where user_name='".$_SESSION['g_user']."') )"; } if (isset ($_GET['date_start']) && isDate($_GET['date_start'])!= null ) { $date_start=$_GET['date_start']; $query.=" and ag_timestamp >= to_date('$date_start','DD.MM.YYYY')"; } if (isset ($_GET['date_end']) && isDate($_GET['date_end'])!= null ) { $date_end=$_GET['date_end']; $query.=" and ag_timestamp <= to_date('$date_end','DD.MM.YYYY')"; } if ( isset($_GET['ag_dest'])) { if ( $_GET['ag_dest']==0) $query .= "and ag_dest is null "; else $query.= " and ag_dest = ".sql_string($_GET['ag_dest']); } $r=$act->myList($p_base,"",$query.$str); echo $r; }