title=_('Choix TVA');
$pop_tva->value='';
echo $pop_tva->input();
$supl_hidden='';
if( isset($_REQUEST['sc']))
$supl_hidden.=HtmlInput::hidden('sc',$_REQUEST['sc']);
if( isset($_REQUEST['f_id']))
$supl_hidden.=HtmlInput::hidden('f_id',$_REQUEST['f_id']);
if( isset($_REQUEST['sb']))
$supl_hidden.=HtmlInput::hidden('sb',$_REQUEST['sb']);
/*--------------------------------------------------------------------------- */
/* We ask to generate the document */
/*--------------------------------------------------------------------------- */
if ( isset($_POST['generate']))
{
$act=new Action($cn);
$act->fromArray($_POST);
if ($act->ag_id == 0 )
{
$act->save();
$ag_id=$act->ag_id;
}
else
{
$act->Update();
}
$act->generate_document($_POST['doc_mod']);
$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 Action($cn);
$act2->fromArray($_POST );
if ( $act2->Update() == false )
{
$sub_action="detail";
}
else
{
ShowActionList($cn,$base);
$url="?$base&sa=detail&ag_id=".$act2->ag_id.'&'.dossier::get();
echo '
';
}
}
//--------------------------------------------------------------------------------
// Show the detail of an action
// permit the update
if ( $sub_action=='detail' )
{
echo '
';
}
//---------------------------------------------------------------------
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 ( ! isset($_REQUEST['see_all'])) $query .= ' and ag_state in (2,3) ';
if ( ! isset($_REQUEST['all_action'])) $query .= " and (ag_owner='".$_SESSION['g_user']."' or ag_dest='".$_SESSION['g_user']."')";
$r=$act->myList($p_base,"",$query.$str);
echo $r;
}