Task #0001731: Moyen de paiement

This commit is contained in:
Dany De Bontridder 2019-08-08 09:06:44 +02:00
parent b21b3bd922
commit 282c26a9f0
13 changed files with 718 additions and 338 deletions

View file

@ -19,133 +19,15 @@
// Copyright Author Dany De Bontridder danydb@aevalys.eu
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/class/acc_payment.class.php';
require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php';
//---------------------------------------------------------------------------
// Common variable
$td='<TD>';
$etd='</td>';
$tr='<tr>';
$etr='</tr>';
$th='<th>';
$eth='</th>';
global $http;
/*!\file
* \brief payment mode
*/
$sb=$http->request('sb', "string","");
echo '<div class="content">';
//----------------------------------------------------------------------
// change
if ( $sb=='change')
{
if ( !isset($_GET['id'])) exit;
$row=new Acc_Payment($cn,$_GET['id']);
$row->load();
echo '<form method="post" id="modify_acc_pay_frm" onsubmit="return confirm_box(\'modify_acc_pay_frm\',\''._('Vous confirmez').'\')">';
echo dossier::hidden();
echo HtmlInput::hidden('sa','mp');
echo HtmlInput::hidden('sb','save');
echo HtmlInput::hidden('id',$row->get_parameter("id"));
echo HtmlInput::hidden('delete_ck',0);
echo $row->form();
echo HtmlInput::submit('save',_('Sauve'), ' onclick="$(\'delete_ck\').value=0"');
echo HtmlInput::submit('delete',_('Efface'),' onclick="$(\'delete_ck\').value=1"');
echo HtmlInput::button_anchor(_('Retour sans sauver'),
'?p_action=divers&sa=mp&'.dossier::get()."&ac=".$_REQUEST['ac'],
"","","smallbutton");
echo '</form>';
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";
}
require_once NOALYSS_INCLUDE."/database/payment_method_sql.class.php";
require_once NOALYSS_INCLUDE."/class/payment_method_mtable.class.php";
//---------------------------------------------------------------------------
// Show form to enter a new one
//---------------------------------------------------------------------------
if ($sb=='ins')
{
$mp=new Acc_Payment($cn);
$r=$mp->blank();
echo '<form method="POST" id="payment_frm" onsubmit="return confirm_box(this,\'Vous confirmez ?\')">';
echo dossier::hidden();
echo HtmlInput::hidden('ac',$_REQUEST['ac']),HtmlInput::hidden('insert',0);
echo $r;
echo HtmlInput::submit('insertsub',_('Enregistre'));
echo HtmlInput::button_anchor(_('Retour sans sauver'),
'?p_action=divers&sa=mp&'.dossier::get()."&ac=".$_REQUEST['ac'],
"","","smallbutton");
echo '</form>';
$payment_method_sql=new Payment_method_SQL($cn);
$payment_method_mtable=new Payment_Method_MTable($payment_method_sql);
return;
}
//--------------------------------------------------------------------------------
//LIST
//--------------------------------------------------------------------------------
/* Get the data from database */
$header=new Sort_Table();
$base_url=$_SERVER['PHP_SELF']."?".Dossier::get()."&ac=".$_REQUEST['ac'];
$payment_method_mtable->add_json_param("op", "payment_method");
$payment_method_mtable->set_callback("ajax_misc.php");
$payment_method_mtable->create_js_script();
$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 payment_method 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 '</div>';
?>
echo $payment_method_mtable->display_table();