noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
payment_middle.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00022 require_once('class_acc_payment.php');
00023 require_once 'class_sort_table.php';
00024 //---------------------------------------------------------------------------
00025 // Common variable
00026 $td='<TD>';
00027 $etd='</td>';
00028 $tr='<tr>';
00029 $etr='</tr>';
00030 $th='<th>';
00031 $eth='</th>';
00032 
00033 /*!\file
00034  * \brief payment mode
00035  */
00036 $sb=HtmlInput::default_value('sb', "", $_REQUEST);
00037 echo '<div class="content">';
00038 
00039 //----------------------------------------------------------------------
00040 // change
00041 if ( $sb=='change')
00042 {
00043     if ( !isset($_GET['id'])) exit;
00044     $row=new Acc_Payment($cn,$_GET['id']);
00045     $row->load();
00046     $javascript="return confirm('"._('Vous confirmez')."')";
00047     echo '<form method="post" onsubmit="'.$javascript.'">';
00048     echo dossier::hidden();
00049     echo HtmlInput::hidden('sa','mp');
00050     echo HtmlInput::hidden('sb','save');
00051     echo HtmlInput::hidden('id',$row->get_parameter("id"));
00052 
00053     echo $row->form();
00054     echo HtmlInput::submit('save',_('Sauve'));
00055     echo HtmlInput::submit('delete',_('Efface'));
00056     echo HtmlInput::button_anchor(_('Retour sans sauver'),
00057                                   '?p_action=divers&sa=mp&'.dossier::get()."&ac=".$_REQUEST['ac']
00058                                      );
00059     echo '</form>';
00060     exit();
00061 }
00062 //----------------------------------------------------------------------
00063 // Save the change
00064 //
00065 if ( $sb=='save')
00066 {
00067     $row=new Acc_Payment($cn,$_POST ['id']);
00068     $row->from_array($_POST);
00069     $row->update();
00070 
00071 }
00072 //---------------------------------------------------------------------------
00073 // Delete a card
00074 //---------------------------------------------------------------------------
00075 if (isset($_POST['delete']))
00076 {
00077     $row=new Acc_Payment($cn,$_POST['id']);
00078     $row->from_array($_POST);
00079     $row->delete();
00080 }
00081 //---------------------------------------------------------------------------
00082 // Insert a new mod of payment
00083 //---------------------------------------------------------------------------
00084 if ( isset($_POST['insert']))
00085 {
00086     $row=new Acc_Payment($cn);
00087     $row->from_array($_POST);
00088     $row->insert();
00089         $sb="list";
00090 }
00091 
00092 //---------------------------------------------------------------------------
00093 // Show form to enter a new one
00094 //---------------------------------------------------------------------------
00095 if ($sb=='ins')
00096 {
00097     $mp=new Acc_Payment($cn);
00098     $r=$mp->blank();
00099     echo '<form method="POST" onsubmit="return confirm(\'Vous confirmez ?\')">';
00100     echo dossier::hidden();
00101         HtmlInput::hidden('ac',$_REQUEST['ac']).HtmlInput::hidden('sb','insert');
00102     echo $r;
00103     echo HtmlInput::submit('insert',_('Enregistre'));
00104     echo HtmlInput::button_anchor(_('Retour sans sauver'),
00105                                   '?p_action=divers&sa=mp&'.dossier::get()."&ac=".$_REQUEST['ac']
00106                                      );
00107     echo '</form>';
00108 
00109     exit();
00110 }
00111 //--------------------------------------------------------------------------------
00112 //LIST
00113 //--------------------------------------------------------------------------------
00114 /* Get the data from database */
00115 $header=new Sort_Table();
00116 $base_url=$_SERVER['PHP_SELF']."?".Dossier::get()."&ac=".$_REQUEST['ac'];
00117 
00118 $header->add("Libelle",$base_url,"order by mp_lib asc","order by mp_lib desc",'la','ld');
00119 $header->add("Pour le journal",$base_url,"order by jrn_def_name asc","order by jrn_def_name  desc",'ja','jd');
00120 $header->add("Type de fiche",$base_url,"order by fd_label asc","order by fd_label desc",'tc','td');
00121 $header->add("Enregistré dans le journal",$base_url,"order by jrn_target asc","order by jrn_target desc",'jta','jtd');
00122 $header->add("Avec la fiche",$base_url,"order by vw_name asc","order by vw_name desc",'na','nd');
00123 
00124 $order=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'la';
00125 
00126 $sql=$header->get_sql_order($order);
00127 
00128 $array=$cn->get_array("
00129         select
00130                         mp_id,mp_lib,mp_jrn_def_id,mp_fd_id,mp_qcode,j.jrn_def_id,
00131                         j.jrn_def_name as jrn_def_name,
00132                         j2.jrn_def_name as jrn_target,
00133                         fd_label,
00134                         coalesce(mp_qcode,'A choisir à l''encodage') as vw_name
00135                         from mod_payment as mp
00136                         left join jrn_def as j on (j.jrn_def_id=mp.jrn_def_id)
00137                         left join jrn_def as j2 on (j2.jrn_def_id=mp.mp_jrn_def_id)
00138                         left join fiche_def as fd on (mp.mp_fd_id=fd.fd_id)
00139                         $sql
00140         ");
00141 /* if there are data show them in a table */
00142 if ( ! empty ($array))
00143 {
00144 
00145         require_once 'template/list_mod_payment.php';
00146         echo HtmlInput::button_anchor("Ajout", $base_url."&sb=ins");
00147 }
00148 echo '</div>';
00149 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations