noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
anc_key_input.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003   Copyright (C) 2014 danydb@aevalys.eu
00004 
00005   This program is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU General Public License
00007   as published by the Free Software Foundation; either version 2
00008   of the License, or (at your option) any later version.
00009 
00010   This program 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 this program; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  * 
00019  */
00020 
00021 /*
00022  * all the pa_id and analytic plan
00023  */
00024 ?>
00025 <form method="post" action="do.php" style="display:inline">
00026     <?php
00027     echo HtmlInput::request_to_hidden(array('gDossier', 'ac'));
00028     echo HtmlInput::hidden('op','consult');
00029     echo HtmlInput::hidden('key', $this->key->getp('id'));
00030     $name=HtmlInput::default_value_post("name_key",$this->key->getp('name'));
00031     $description_text=HtmlInput::default_value_post("description_key",$this->key->getp('description'));
00032     ?>
00033     <div class="content">
00034         <div style="width:30%;display:inline-block;min-height: 75px">
00035                     <?php
00036                         $name=new IText('name_key',$name);
00037                         echo $name->input();
00038                     ?>
00039         </div>
00040         <div style="width: 65%;display:inline-block;min-height: 75px">
00041                 <?php
00042                         $description=new IText('description_key',$description_text);
00043                         $description->css_size='70%';
00044                         echo $description->input();
00045                     ?>
00046         </div>
00047         <h2>
00048             <?php echo _('Répartition'); ?>
00049         </h2>
00050         <table id="key_account_tb" class="result" style="margin-left: 8%;width:84%;margin-right:8%">
00051             <tr>
00052                 <th><?php echo _('n°'); ?></th>
00053                 <?php
00054                 // Show all the possible analytic plan
00055                 for ($i=0; $i<count($plan); $i++):
00056                     ?>
00057                     <th>
00058                         <?php echo $plan[$i]['pa_name']; ?>
00059                     </th>
00060                     <?php
00061                 endfor;
00062                 ?>
00063                     <th style="text-align: right">
00064                     <?php echo _('Pourcentage'); ?>
00065                     <?php echo HtmlInput::infobulle(41); ?>
00066                 </th>
00067             </tr>
00068             <?php
00069             $count_row=count($a_row);
00070             if ($count_row == 0 ) {
00071                 $a_row [0]['ke_row']=1;
00072                 $a_row [0]['ke_percent']=0;
00073                 $a_row [0]['ke_id']=-1;
00074                 
00075             }
00076             $tot_key=0;
00077             for ($j=0; $j<count($a_row); $j++):
00078                 ?>
00079                 <tr>
00080                     <td>
00081                     <?php echo $a_row[$j]['ke_row']; ?>
00082                         <?php echo HtmlInput::hidden('row[]', $a_row[$j]['ke_id']); ?>
00083                     </td>
00084                         <?php
00085                          $percent=$a_row[$j]['ke_percent'];
00086                          $tot_key=bcadd($tot_key,$percent);
00087                         // For each plan
00088                         for ($i=0; $i<count($plan); $i++):
00089                             if ( $j == 0 ) {
00090                                 echo HtmlInput::hidden('pa[]',$plan[$i]['pa_id']);
00091                             }
00092                             $a_poste=$cn->make_array("select po_id,po_name from poste_analytique where pa_id=$1", 1, array($plan[$i]['pa_id']));
00093                             $select=new ISelect('po_id['.$j.'][]');
00094                             $select->value=$a_poste;
00095                             $value=$cn->get_array('select po_id,ke_percent 
00096                                 from key_distribution_activity as ka
00097                                 join key_distribution_detail using (ke_id) 
00098                                 join key_distribution using (kd_id) 
00099                                 left join poste_analytique using(po_id)
00100                                 
00101                         where ke_id=$1 and ka.pa_id=$2 ', array($a_row[$j]['ke_id'],$plan[$i]['pa_id']));
00102                             $selected=-1;
00103                             if (sizeof($value)==1)
00104                             {
00105                                 $selected=$value[0]['po_id'];
00106                                
00107                             }
00108                             if (isset($_POST['po_id']))
00109                             {
00110                                 $a_po_id=HtmlInput::default_value_post('po_id', array());
00111                                 $selected=$a_po_id[$j][$i];
00112                                 $a_percent=HtmlInput::default_value_post('percent', array());
00113                                 $percent=$a_percent[$j];
00114                             }
00115                             $select->selected=$selected;
00116                             ?>
00117                         <td>
00118                             <?php
00119                             echo $select->input();
00120                             ?>                
00121                         </td>
00122                         <?php
00123                     endfor;
00124                     ?>
00125                         <td class="num">
00126                         <?php
00127                         $inum_percent=new INum('percent[]');
00128                         $inum_percent->javascript=' onchange="format_number(this,2);anc_key_compute_table();"';
00129                         $inum_percent->value=sprintf("%.2f",$percent);
00130                         echo $inum_percent->input();
00131                         ?>
00132                     </td>
00133                 </tr>
00134                 <?php
00135             endfor;
00136             ?>
00137                 <tfoot style="font-weight: bolder">
00138                     <tr>
00139                         <td style="width: auto" colspan="<?php echo count($plan)+1;?>">
00140                             <?php echo _('Total')?>
00141                         </td>
00142                         <td  class="num">
00143                             <span id="total_key"><?php echo nb($tot_key);?></span>%
00144                         </td>
00145                     </tr>
00146                 </tfoot>
00147         </table>
00148 <input type="button" class="smallbutton" value="<?php echo _('Ajout ligne')?>" onclick="add_row_key('key_account_tb');">
00149 
00150         <div>
00151             <div>
00152                 <h2>
00153                     <?php echo _("Disponible dans les journaux "); ?>
00154                 </h2>
00155             </div>
00156             <div style="margin-left: 8%;width:84%;margin-right:8%">
00157 
00158                 <?php 
00159                 if ( $this->key->getp("id") == -1 )
00160                 {
00161                     // for a new key
00162                         $jrn=$cn->get_array('select null as kl_id,jrn_def_id,jrn_def_name,jrn_def_description 
00163                                             from jrn_def 
00164                                             order by jrn_def_name ');
00165                 }else {
00166                     // for an existing one
00167                         $jrn=$cn->get_array('select kl_id,jrn_def_id,jrn_def_name,jrn_def_description 
00168                                             from jrn_def 
00169                                             left join key_distribution_ledger using (jrn_def_id)
00170                                             where kd_id=$1 or kd_id is null
00171                                             order by jrn_def_name ', array($this->key->getp('id')));
00172                 }
00173                 $post_jrn=HtmlInput::default_value_post("jrn",-1);
00174                 ?>
00175                 <table id="jrn_def_tb" class="result">
00176                     <?php for ($i=0; $i<count($jrn); $i++): ?>
00177                         <tr>
00178                             <td>
00179                                 <?php $checkbox=new ICheckBox("jrn[]"); ?>
00180                                 <?php $checkbox->value=$jrn[$i]['jrn_def_id']; ?>
00181                                 <?php
00182                                 $checkbox->selected=false;
00183                                 if ( ($post_jrn == -1 && $jrn[$i]['kl_id']<>"" ) || (is_array($post_jrn) && in_array($jrn[$i]['jrn_def_id'], $post_jrn)))
00184                                 {
00185                                     $checkbox->selected=true;
00186                                 }
00187                                 ?>
00188                                 <?php echo $checkbox->input(); ?>
00189                             </td>
00190                             <td>
00191                                 <?php echo h($jrn[$i]['jrn_def_name']); ?>
00192                             </td>
00193                             <td>
00194                                 <?php echo h($jrn[$i]['jrn_def_description']); ?>
00195                             </td>
00196                         </tr>
00197                     <?php endfor; ?>
00198                 </table>
00199             </div>
00200         </div>
00201 
00202         <!-- end -->
00203     </div>
00204     <?php echo HtmlInput::submit('save_key', _('Sauver')); ?>
00205 </form>
00206 <form style="display:inline" action="do.php" method="post">
00207     <?php
00208     echo HtmlInput::request_to_hidden(array('gDossier', 'ac'));
00209     echo HtmlInput::hidden('op','delete_key');
00210     echo HtmlInput::hidden('key', $this->key->getp('id'));
00211    if ($this->key->getp('id') != -1) echo HtmlInput::submit('delete_key', _('Effacer'),'onclick="return confirm(\''._('Confirmer effacement?').'\')"'); ?>
00212 </form>
 All Data Structures Namespaces Files Functions Variables Enumerations