';
$etd='';
$tr='
';
$etr='
';
$th='';
$eth=' | ';
global $http;
/*!\file
* \brief payment mode
*/
$sb=$http->request('sb', "string","");
echo '';
//----------------------------------------------------------------------
// change
if ( $sb=='change')
{
if ( !isset($_GET['id'])) exit;
$row=new Acc_Payment($cn,$_GET['id']);
$row->load();
echo '';
return;
}
//----------------------------------------------------------------------
// Save the change
//
if ( $sb=='save')
{
$http=new HttpInput();
$delete=$http->post("delete_ck","string", 0);
if ( $delete == 0 )
{
$row=new Acc_Payment($cn,$_POST ['id']);
$row->from_array($_POST);
$row->update();
} else {
//---------------------------------------------------------------------------
// Delete a card
//---------------------------------------------------------------------------
$row=new Acc_Payment($cn,$_POST['id']);
$row->from_array($_POST);
$row->delete();
}
}
//---------------------------------------------------------------------------
// Insert a new mod of payment
//---------------------------------------------------------------------------
if ( isset($_POST['insert']))
{
$row=new Acc_Payment($cn);
$row->from_array($_POST);
$row->insert();
$sb="list";
}
//---------------------------------------------------------------------------
// Show form to enter a new one
//---------------------------------------------------------------------------
if ($sb=='ins')
{
$mp=new Acc_Payment($cn);
$r=$mp->blank();
echo '';
return;
}
//--------------------------------------------------------------------------------
//LIST
//--------------------------------------------------------------------------------
/* Get the data from database */
$header=new Sort_Table();
$base_url=$_SERVER['PHP_SELF']."?".Dossier::get()."&ac=".$_REQUEST['ac'];
$header->add(_("Libelle"),$base_url,"order by mp_lib asc","order by mp_lib desc",'la','ld');
$header->add(_("Pour le journal"),$base_url,"order by jrn_def_name asc","order by jrn_def_name desc",'ja','jd');
$header->add(_("Type de fiche"),$base_url,"order by fd_label asc","order by fd_label desc",'tc','td');
$header->add(_("Enregistré dans le journal"),$base_url,"order by jrn_target asc","order by jrn_target desc",'jta','jtd');
$header->add(_("Avec la fiche"),$base_url,"order by vw_name asc","order by vw_name desc",'na','nd');
$order=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'la';
$sql=$header->get_sql_order($order);
$array=$cn->get_array("
select
mp_id,mp_lib,mp_jrn_def_id,mp_fd_id,mp_qcode,j.jrn_def_id,
j.jrn_def_name as jrn_def_name,
j2.jrn_def_name as jrn_target,
fd_label,
coalesce(mp_qcode,'A choisir à l''encodage') as vw_name
from mod_payment as mp
left join jrn_def as j on (j.jrn_def_id=mp.jrn_def_id)
left join jrn_def as j2 on (j2.jrn_def_id=mp.mp_jrn_def_id)
left join fiche_def as fd on (mp.mp_fd_id=fd.fd_id)
$sql
");
/* if there are data show them in a table */
if ( ! empty ($array))
{
require_once NOALYSS_TEMPLATE.'/list_mod_payment.php';
}
echo HtmlInput::button_anchor("Ajout", $base_url."&sb=ins","","","smallbutton");
echo '
';
?>