412: réécriture ODS

This commit is contained in:
Dany De Bontridder 2011-11-02 19:04:26 +00:00
parent a809fd6666
commit 281b6e7482
6 changed files with 199 additions and 164 deletions

View file

@ -44,6 +44,13 @@ function update_predef(p_type,p_direct)
}
);
}
/**
*@brief update ctl id =jrn_name with the value of p_jrn
*/
function update_name()
{
$('jrn_name').innerHTML=$('p_jrn').options[$('p_jrn').selectedIndex].innerHTML;
}
/**
* @brief update the field predef
*/

View file

@ -921,3 +921,27 @@ table.result td
padding-left:5px;
padding-right:5px;
}
table.info_op
{
margin-left: 30%;
margin-right: 30%;
width:20%;
}
table.info_op tr
{
font-size:14;
background:white;
width:5%
}
h2#jrn_name
{
margin-left:30%;
}
tr.footer{
font-size:14;
font-style: italic;
font-weight: bold;
}

View file

@ -184,10 +184,11 @@ div.u_redcontent{
div.content{
float:left;
padding-top:7px;
width:100%;
width:96%;
font-family:helvetica,arial,sans-serif;
clear:both;
margin-left:2%;
}
div.content30{
@ -955,3 +956,30 @@ table.result td
padding-left:5px;
padding-right:5px;
}
table.info_op
{
margin-left: 30%;
margin-right: 30%;
width:20%;
}
table.info_op tr
{
font-size:14;
background:white;
width:5%
}
h2#jrn_name
{
margin-right:50%;
float:right;
font-size:18;
display: inline;
color:#15158e;
}
tr.footer{
font-size:14;
font-style: italic;
font-weight: bold;
}

View file

@ -951,3 +951,27 @@ table.result td
padding-left:5px;
padding-right:5px;
}
table.info_op
{
font-size:18;
margin-right:30%;
width:20%;
}
table.info_op tr
{
font-size:14;
background:white;
}
h2#jrn_name
{
margin-left:30%;
float: right;
}
tr.footer{
font-size:14;
font-style: italic;
font-weight: bold;
}

View file

@ -1207,7 +1207,7 @@ class Acc_Ledger
* \param $p_array array from the form
* \return string
*/
function show_summary($p_array)
function confirm($p_array,$p_readonly=false)
{
$this->id=$p_array['p_jrn'];
if ( empty($p_array)) return 'Aucun résultat';
@ -1223,22 +1223,25 @@ class Acc_Ledger
$lPeriode->find_periode($e_date);
}
$owner=new own($this->db);
$total=0;
bcscale(2);
$ret="";
$ret.="<table>";
$ret.="<table >";
$ret.="<tr><td>"._('Date')." : </td><td>$e_date</td></tr>";
/* display periode */
$date_limit=$lPeriode->get_date_limit();
$ret.='<tr><td> '._('Période Comptable').' '.$date_limit['p_start'].'-'.$date_limit['p_end'].'</td></tr>';
$ret.='<tr> '.td(_('Période Comptable')).td($date_limit['p_start'].'-'.$date_limit['p_end']).'</tr>';
$ret.="<tr><td>"._('Libellé')." </td><td>".h($desc)."</td></tr>";
$ret.="<tr><td>"._('PJ Num')." </td><td>".h($e_pj)."</td></tr>";
$ret.='</table>';
$ret.="<table>";
$ret.="<table class=\"result\">";
$ret.="<tr>";
$ret.="<th>"._('Quick Code ou');
$ret.="<th>"._('Quick Code ou ');
$ret.=_("Poste")." </th>";
$ret.="<th style=\"text-align:right\"> "._("Montant")." </th>";
$ret.="<th>"._("Débit")."</th>";
$ret.="<th style=\"text-align:left\"> "._("Libellé")." </th>";
$ret.="<th style=\"text-align:right\">"._("Débit")."</th>";
$ret.="<th style=\"text-align:right\">"._("Crédit")."</th>";
/* if we use the AC */
if ($owner->MY_ANALYTIC!='nu')
{
@ -1246,7 +1249,7 @@ class Acc_Ledger
$a_anc=$anc->get_list();
$x=count($a_anc);
/* set the width of the col */
$ret.='<th colspan="'.$x.'">'._('Compt. Analytique').'</th>';
$ret.='<th colspan="'.$x.'" style="width:auto;text-align:center" >'._('Compt. Analytique').'</th>';
/* add hidden variables pa[] to hold the value of pa_id */
$ret.=Anc_Plan::hidden($a_anc);
@ -1273,6 +1276,12 @@ class Acc_Ledger
$count=0;
for ($i=0;$i<$nb_item;$i++)
{
if ( $p_readonly == true )
{
if ( ! isset (${'qc_'.$i})) ${'qc_'.$i}='';
if ( ! isset (${'poste'.$i})) ${'poste'.$i}='';
if ( ! isset (${'amount'.$i})) ${'amount'.$i}='';
}
$ret.="<tr>";
if ( trim(${'qc_'.$i})!="")
{
@ -1298,9 +1307,12 @@ class Acc_Ledger
if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "")
continue;
$ret.="<td>".h(${"ld".$i}).HtmlInput::hidden('ld'.$i,${'ld'.$i})."</td>";
$ret.="<td>".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i})."</td>";
if ( isset(${"ck$i"}))
$ret.="<td class=\"num\">".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i})."</td>".td("");
else
$ret.=td("")."<td class=\"num\">".${"amount".$i}.HtmlInput::hidden('amount'.$i,${'amount'.$i})."</td>";
$total=bcadd($total,${"amount".$i});
$ret.="<td>";
$ret.=(isset(${"ck$i"}))?"D":"C";
$ret.=(isset(${"ck$i"}))?HtmlInput::hidden('ck'.$i,${'ck'.$i}):"";
$ret.="</td>";
// CA
@ -1316,8 +1328,9 @@ class Acc_Ledger
/* op is the operation it contains either a sequence or a jrnx.j_id */
$ret.=HtmlInput::hidden('op[]=',$i);
$ret.='<td>';
$ret.=$op->display_form_plan($p_array,$null,1,$count,round(${'amount'.$i},2));
$ret.='<td style="text-align:center">';
$read=($p_readonly==true)?0:1;
$ret.=$op->display_form_plan($p_array,$null,$read,$count,round(${'amount'.$i},2));
$ret.='</td>';
$count++;
}
@ -1329,8 +1342,10 @@ class Acc_Ledger
$ret.="</tr>";
}
$ret.=tr(td('').td(_('Totaux')).td($total,'class="num"').td($total,'class="num"'),'class="footer"');
$ret.="</table>";
if ( $owner->MY_ANALYTIC!='nu' ) $ret.='<input type="button" class="button" value="'._('verifie CA').'" onClick="verify_ca(\'\');">';
if ( $owner->MY_ANALYTIC!='nu' && $p_readonly==false)
$ret.='<input type="button" class="button" value="'._('verifie Imputation Analytique').'" onClick="verify_ca(\'\');">';
return $ret;
}
@ -1341,7 +1356,7 @@ class Acc_Ledger
*
* \return a string containing the form
*/
function show_form($p_array=null,$p_readonly=0)
function input($p_array=null,$p_readonly=0)
{
$user = new User($this->db);
$owner=new Own($this->db);
@ -1351,6 +1366,12 @@ class Acc_Ledger
if ( $p_array != null )
extract($p_array);
$add_js="";
if ( $owner->MY_PJ_SUGGEST=='Y')
{
$add_js="update_pj();";
}
$add_js.='get_last_date();';
$ret="";
/* Add button */
@ -1359,7 +1380,15 @@ class Acc_Ledger
$f_add_button->set_attribute('ipopup','ipop_newcard');
$f_add_button->set_attribute('jrn',$this->id);
$f_add_button->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);";
$ret.=$f_add_button->input();
$f_add_button->input();
$wLedger=$this->select_ledger('ODS',2);
if ($wLedger == null) exit (_('Pas de journal disponible'));
$wLedger->javascript="onChange='update_name();update_predef(\"ods\",\"t\");$add_js'";
$label=" Journal ".HtmlInput::infobulle(2) ;
$ret.=$label.$wLedger->input();
// Load the javascript
//
@ -1435,12 +1464,12 @@ class Acc_Ledger
$ret.=HtmlInput::hidden('nb_item',$nb_row);
$ret.=dossier::hidden();
$ret.=HtmlInput::hidden('p_jrn',$this->id);
$ret.=dossier::hidden();
$ret.=HtmlInput::hidden('jrn_type',$this->get_type());
$info= HtmlInput::infobulle(0);
$info_poste=HtmlInput::infobulle(9);
$ret.=$f_add_button->input();
$ret.='<table id="quick_item" style="width:100%">';
$ret.='<tr>'.
'<th >Quickcode'.$info.'</th>'.
@ -2893,4 +2922,6 @@ class Acc_Ledger
$first_name=$this->db->get_value('select ad_value from fiche_detail where ad_id=32 and f_id=$1',array($tiers));
return $name.' '.$first_name;
}
}

View file

@ -20,7 +20,7 @@
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\file
/* !\file
*
*
* \brief to write directly into the ledgers,the stock and the tables
@ -35,118 +35,81 @@ require_once('class_periode.php');
require_once('function_javascript.php');
require_once('class_ipopup.php');
global $g_user;
$cn = new Database(dossier::id());
$id = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : -1;
$ledger = new Acc_Ledger($cn, $id);
$first_ledger = $ledger->get_first('ODS');
$ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id;
/* !\brief show a form for quick_writing */
$id = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : -1;
$def = -1;
$ledger->with_concerned = true;
$cn=new Database(dossier::id());
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
/*!\brief show a form for quick_writing */
function show_qw_menu($def=0)
if ($g_user->check_jrn($id) == 'X')
{
echo '<div class="lmenu">';
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
echo ShowItem(
array(
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get().'&p_jrn='.$id.'&show_form',_('Encoder une Operation'),
_('Encoder une operation dans ce journal'),0),
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get().'&p_jrn='.$id.'&sa=l',_('Voir Operation'),
_('Voir les operations de ce journal'),1),
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get(),
_('Autre journal'),
_('Choisir un autre journal')
)),
'H',"mtitle","mtitle",$def,' style="width:80%;margin-left:5;"'
);
echo '</div>';
NoAccess();
exit - 1;
}
/*!\brief show a form for quick_writing */
function show_direct_form($cn,$ledger,$p_array)
if (!isset($_POST['summary']) && !isset($_POST['save']))
{
echo '<div class="content">';
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
// Show the predef operation
// Don't forget the p_jrn
echo '<form method="get">';
echo HtmlInput::hidden('p_action',$_REQUEST['p_action']);
echo dossier::hidden();
echo HtmlInput::hidden('p_jrn',$_REQUEST['p_jrn']);
$op=new Pre_operation($cn);
$op->p_jrn=$_REQUEST['p_jrn'];
$op->od_direct='t';
if ( $op->count() > 0 )
{
echo _("Utilisez une operation ");
echo $op->show_button();
echo HtmlInput::submit('use_opd',_('Utilisez une operation'));
}
echo '</form>';
echo '<form method="post" action="?" class="print">';
echo dossier::hidden();
echo HtmlInput::hidden('p_action',$_REQUEST['p_action']);
echo $ledger->show_form($p_array);
echo HtmlInput::button('add',_('Ajout d\'une ligne'),'onClick="quick_writing_add_row()"');
echo HtmlInput::submit('summary',_('Sauvez'));
echo '<div class="info">'.
_('Débit').' = <span id="totalDeb"></span>'.
_('Crédit').' = <span id="totalCred"></span>'.
_('Difference').' = <span id="totalDiff"></span></div> ';
echo '</form>';
echo "<script>checkTotalDirect();</script>";
echo create_script(" get_last_date()");
echo '</div>';
require('operation_ods_new.inc.php');
exit();
}
$ledger=new Acc_Ledger($cn,$id);
$ledger->with_concerned=true;
// no ledger selected, propose one
// Only ODS
if ($id == -1 )
elseif (isset($_POST['summary']))
{
echo '<div class="content">';
// Vide
echo '<FORM method="get" action="?">';
echo dossier::hidden();
echo HtmlInput::hidden('p_action',$_REQUEST['p_action']);
echo $ledger->select_ledger('ODS',3)->input();
echo HtmlInput::submit('show_form',_('Choix du journal'));
echo '</form>';
echo '</div>';
exit();
require_once 'operation_ods_confirm.inc.php';
exit();
}
if ( $User->check_jrn($id) == 'X' )
elseif (isset($_POST['save']))
{
$array = $_POST;
try
{
$ledger->save($array);
$jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal));
echo '<h2> Op&eacute;ration enregistr&eacute;e Piece ' . h($ledger->pj) . '</h2>';
if (strcmp($ledger->pj, $_POST['e_pj']) != 0)
{
echo '<h3 class="notice">' . _('Attention numéro pièce existante, elle a du être adaptée') . '</h3>';
}
printf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>', $jr_id, dossier::id(), $ledger->internal);
// show feedback
echo $ledger->confirm($_POST, true);
}
catch (Exception $e)
{
require('operation_ods_new.inc.php');
alert($e->getMessage());
}
exit();
}
exit();
if ( $g_user->check_jrn($id) == 'X' )
{
alert(_("L'acces a ce journal est interdit, \n contactez votre responsable"));
exit();
}
echo '<div class="content">';
echo '<div style="float:right;margin-right:30">';
echo '<h2 class="info"> '._('Journal').' : '.$ledger->get_name().'</h2>';
echo '</div>';
$sa=( isset ($_REQUEST['sa']))?$_REQUEST['sa']:'';
//======================================================================
// See the ledger listing
if ($sa == 'l' && $id != -1)
{
// Check privilege
if ( $User->check_jrn($id) == 'X')
if ( $g_user->check_jrn($id) == 'X')
{
NoAccess();
exit -1;
@ -154,19 +117,19 @@ if ($sa == 'l' && $id != -1)
show_qw_menu(1);
echo '<div class="content">';
$Ledger=new Acc_Ledger($cn,$id);
$type=$Ledger->get_type();
$href=basename($_SERVER['PHP_SELF']);
echo '<form method="GET" action="'.$href.'">';
echo HtmlInput::hidden("sa","l");
echo HtmlInput::hidden("p_jrn",$id);
echo HtmlInput::hidden("p_action","quick_writing");
echo HtmlInput::hidden("ac",$_REQUEST['sa']);
echo dossier::hidden();
echo $Ledger->search_form($type,0);
echo HtmlInput::submit("qwlist",_("Recherche"));
echo '</form>';
$array=$_GET;
list($sql,$where)=$Ledger->build_search_sql($array);
@ -185,7 +148,7 @@ if ($sa == 'l' && $id != -1)
/*
* Export to csv
*/
$r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcode','accounting','unpaid','gDossier','ledger_type','p_action'));
$r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcode','accounting','unpaid','gDossier','ledger_type','ac'));
if (isset($_GET['r_jrn'])) {
foreach ($_GET['r_jrn'] as $k=>$v)
$r.=HtmlInput::hidden('r_jrn['.$k.']',$v);
@ -205,27 +168,20 @@ if ($sa == 'l' && $id != -1)
// User can write ?
// Write into the ledger
if ( $User->check_jrn($id) == 'X' )
if ( $g_user->check_jrn($id) == 'X' )
{
alert(_("Vous ne pouvez pas accèder à ce journal, contactez votre responsable"));
exit -1;
}
if ( $User->check_jrn($id)=='W' )
if ( $g_user->check_jrn($id)=='W' )
{
if ( isset($_GET['show_form']) || isset($_POST['correct_it']) )
if ( ($sa=='n' || isset($_POST['correct_it'])) && ! isset($_POST['summary']))
{
$array=$_POST;
$default_periode=$User->get_periode();
$default_periode=$g_user->get_periode();
/* check if the ledger is closed */
if ( $ledger->is_closed($default_periode)==1)
{
echo '<h2 class="error">'._('Désolé mais cette periode est fermee pour ce journal').'</h2>';
exit();
}
$periode=new Periode($cn);
list($date,$devnull)=$periode->first_day($default_periode);
$array['date']=$date;
show_qw_menu();
show_direct_form($cn,$ledger,$array);
exit();
@ -250,42 +206,7 @@ if ( $User->check_jrn($id)=='W' )
exit();
}
if ( isset($_POST['summary']))
{
try
{
$ledger->verify($_POST );
}
catch (Exception $e)
{
alert($e->getMessage());
show_qw_menu();
show_direct_form($cn,$ledger,$_POST);
exit();
}
echo '<form method="post" action="?">';
echo $ledger->show_form($_POST,1);
echo dossier::hidden();
echo HtmlInput::hidden('p_action',$_REQUEST['p_action']);
echo '<hr>';
$chk=new ICheckBox();
$chk->selected=false;
echo $chk->input('opd_save');
echo "Sauvez cette op&eacute;ration comme modèle d'opération ?";
echo '<br/>';
$opd_name=new IText('opd_name');
echo "Nom du modèle ".$opd_name->input();
echo '<br/>';
echo HtmlInput::submit('save_it',"Sauver",'onClick="return verify_ca();"');
echo HtmlInput::submit('correct_it','Corriger');
echo '</form>';
exit();
}
if ( isset($_POST['save_it' ]))
{
$array=$_POST;