Add the quick / direct writing ability
This commit is contained in:
parent
15ce1362e9
commit
26afef570a
28 changed files with 656 additions and 122 deletions
131
include/quick_writing.inc.php
Normal file
131
include/quick_writing.inc.php
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief to write directly into the ledgers,the stock and the tables
|
||||
* quant_purchase and quant_sold are not changed by this
|
||||
*
|
||||
*/
|
||||
require_once ('class_acc_ledger.php');
|
||||
|
||||
$cn=DbConnect(dossier::id());
|
||||
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
|
||||
|
||||
function show_direct_form($cn,$ledger,$p_array) {
|
||||
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
|
||||
|
||||
// Show the predef operation
|
||||
// Don't forget the p_jrn
|
||||
echo '<form>';
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden('p_action',$_REQUEST['p_action']);
|
||||
|
||||
echo '<input type="hidden" value="'.$id.'" name="p_jrn">';
|
||||
$op=new Pre_operation($cn);
|
||||
$op->p_jrn=$id;
|
||||
$op->od_direct='t';
|
||||
if ($op->count() != 0 )
|
||||
echo widget::submit_button('use_opd','Utilisez une op.prédéfinie');
|
||||
echo $op->show_button();
|
||||
echo '</form>';
|
||||
|
||||
echo '<form method="post" action="?">';
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden('p_action',$_REQUEST['p_action']);
|
||||
|
||||
echo $ledger->show_form($p_array);
|
||||
|
||||
echo widget::submit_button('summary','Sauvez');
|
||||
|
||||
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$ledger=new Acc_Ledger($cn,$id);
|
||||
// no ledger selected, propose one
|
||||
if ($id == -1 )
|
||||
{
|
||||
|
||||
// Vide
|
||||
echo '<FORM method="get" action="?">';
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden('p_action',$_REQUEST['p_action']);
|
||||
echo $ledger->select_ledger()->IOValue();
|
||||
echo widget::submit_button('show_form','Choix du journal');
|
||||
echo '</form>';
|
||||
exit();
|
||||
}
|
||||
echo '<div class="u_content">';
|
||||
echo '<h2 class="info"> Journal : '.$ledger->GetName().'</h2>';
|
||||
echo widget::button_href('Autre journal','?p_action='.$_REQUEST['p_action'].'&'.dossier::get());
|
||||
|
||||
if ( isset($_GET['show_form']) || isset($_POST['correct_it']) ) {
|
||||
show_direct_form($cn,$ledger,$_POST);
|
||||
exit();
|
||||
}
|
||||
|
||||
// reload with a predefined operation
|
||||
//
|
||||
if ( isset ($_GET['use_opd'])) {
|
||||
$op=new Pre_op_advanced($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
//$op->p_jrn=$id;
|
||||
|
||||
$p_post=$op->compute_array();
|
||||
show_direct_form($cn,$ledger,$p_post);
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
if ( isset($_POST['summary'])) {
|
||||
echo '<form method="post" action="?">';
|
||||
echo $ledger->show_form($_POST,1);
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden('p_action',$_REQUEST['p_action']);
|
||||
|
||||
echo widget::submit_button('save_it',"Sauver");
|
||||
echo widget::submit_button('correct_it','Corriger');
|
||||
|
||||
$chk=new widget('checkbox');
|
||||
$chk->selected=false;
|
||||
echo "Sauvez l'opération ?";
|
||||
echo $chk->IOValue('save_opd');
|
||||
|
||||
echo '</form>';
|
||||
exit();
|
||||
|
||||
}
|
||||
if ( isset($_POST['save_it' ])) {
|
||||
$array=$_POST;
|
||||
|
||||
try {
|
||||
$ledger->save($array);
|
||||
} catch (AcException $e) {
|
||||
echo '<script>alert (\''.$e->getMessage()."'); </script>";
|
||||
show_direct_form($cn,$ledger,$_POST);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue