can_request($cn,SEC_ACTION);
//-----------------------------------------------------
// Action
//-----------------------------------------------------
require_once("class_widget.php");
require_once("class_action.php");
/*!\brief Show the list of action, this code should be common
* to several webpage. But for the moment we keep like that
* because it is used only by this file.
*\param $cn database connection
* \param $retour button for going back
* \param $h_url calling url
*/
function ShowActionList($cn,$retour,$h_url)
{
// 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_exp= ".$fiche->id." or ".
"f_id_dest=".$fiche->id.")";
}
}
$r=$act->myList(ACTION,$query.$str);
echo $r;
}
// We need a sub action (3rd level)
// show a list of already taken action
// propose to add one
// permit also a search
// show detail
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
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
// TODO add function for generating url, hidden tags...
//$retour='';
$retour="";
$h_url="";
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('',urldecode($_REQUEST['url']));
$h_url=sprintf('',urldecode($_REQUEST['url']));
}
//----------------------------------------------------------------------
// Update the detail
// Add a new action related to this one or update
//----------------------------------------------------------------------
if ( $sub_action=="update" )
{
// Update the modification
if ( isset($_POST['save']))
{
$act=new action($cn);
$act=new action($cn);
$act->ag_id=$_POST['ag_id'];
$act->ag_comment=$_POST['ag_comment'];
$act->ag_timestamp=$_POST['ag_timestamp'];
$act->d_state=$_POST['d_state'];
$act->dt_id=(isset($_POST['dt_id']))?$_POST['dt_id']:0;
$act->qcode_exp=$_POST['qcode_exp'];
$act->qcode_dest=$_POST['qcode_dest'];
$act->ag_title=$_POST['ag_title'];
$act->d_id=(isset($_POST['d_id']))?$_POST['d_id']:0;
$act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:0;
if ( $act->Update() == false ) {
$sub_action="detail";
}
else
{
ShowActionList($cn,$retour,$h_url);
}
}
//----------------------------------------------------------------------
// Add a related action
//----------------------------------------------------------------------
if ( isset ($_POST['add_action_here']) )
{
$act=new action($cn);
$act->ag_ref_ag_id=$_POST['ag_id'];
//----------------------------------------
// puis comme ajout normal (copier / coller )
echo $retour;
$act->ag_id=0;
$act->qcode_dest=(isset($_POST['qcode_dest']))?$_REQUEST['qcode_dest']:"";
$act->qcode_exp=(isset($_POST['qcode_exp']))?$_REQUEST['qcode_exp']:"";
$act->f_id_dest=(isset($_POST['f_id_dest']))?$_POST['f_id_dest']:0;
$act->f_id_exp=(isset($_POST['f_id_exp']))?$_POST['f_id_exp']:0;
$act->ag_ref_ag_id=$_POST['ag_id'];
$act->ag_timestamp=(isset($_POST['ag_timestamp']))?$_POST['ag_timestamp']:"";
$act->qcode_dest=isset($_POST['qcode_dest'])?$_REQUEST['qcode_dest']:"";
$act->qcode_exp=isset($_POST['qcode_exp'])?$_REQUEST['qcode_exp']:"";
$act->d_id=0;
$act->dt_id=isset($_POST['dt_id'])?$_REQUEST['dt_id']:"";
$act->d_state=(isset($_POST['d_state']))?$_POST['d_state']:"";
$act->ag_ref="";
$act->ag_title=(isset($_POST['ag_title']))?$_POST['ag_title']:"";
echo '
';
echo JS_SEARCH_CARD;
// Add hidden tag
echo ''.
'
';
}
}
//--------------------------------------------------------------------------------
// Show the detail of an action
// permit the update
if ( $sub_action=='detail' )
{
echo '