file:///home/developper/svn/phpcompta/branches/rel510 ........ r3286 | danydb | 2010-06-12 19:24:49 +0200 (Sat, 12 Jun 2010) | 2 lines Check if database is valid ........ r3287 | danydb | 2010-06-12 20:41:47 +0200 (Sat, 12 Jun 2010) | 1 line Fix bug : when using twice the same accounting in operation, one of them is not visible in "impression->poste" ........ r3288 | danydb | 2010-06-12 21:04:36 +0200 (Sat, 12 Jun 2010) | 2 lines Cosmetic ........ r3289 | danydb | 2010-06-12 21:14:07 +0200 (Sat, 12 Jun 2010) | 1 line Cosmetic : fix CSS ........ r3290 | danydb | 2010-06-12 21:17:05 +0200 (Sat, 12 Jun 2010) | 2 lines Fix CSS ........ r3291 | danydb | 2010-06-12 21:48:52 +0200 (Sat, 12 Jun 2010) | 3 lines Cosmetic : fix CSS An user who is NOT admin and can access only ONE folder is automatically redirected to the plugins or the dashboard ........ r3292 | danydb | 2010-06-14 20:38:39 +0200 (Mon, 14 Jun 2010) | 2 lines Cosmetic highlight row for lettering ........ r3293 | danydb | 2010-06-14 20:38:52 +0200 (Mon, 14 Jun 2010) | 2 lines Highlight row of lettering ........ r3294 | danydb | 2010-06-14 20:41:53 +0200 (Mon, 14 Jun 2010) | 1 line Lettering : if an operation is removed : the lettering is also removed on both side ........ r3295 | danydb | 2010-06-14 20:43:50 +0200 (Mon, 14 Jun 2010) | 1 line rename upgrade80 ........ r3296 | danydb | 2010-06-14 20:49:40 +0200 (Mon, 14 Jun 2010) | 2 lines cosmetic : parameter -> societe align to right ........ r3297 | danydb | 2010-06-14 20:50:38 +0200 (Mon, 14 Jun 2010) | 2 lines width set auto for the table ........ r3298 | danydb | 2010-06-14 21:04:09 +0200 (Mon, 14 Jun 2010) | 1 line Lettering : if an operation is removed : the lettering is also removed on both side ........ r3299 | danydb | 2010-06-14 21:25:04 +0200 (Mon, 14 Jun 2010) | 2 lines Fix problem with offset unlimited ........ r3300 | danydb | 2010-06-14 21:57:45 +0200 (Mon, 14 Jun 2010) | 1 line Update the doc == Lettering : if an operation is removed : the lettering is also removed on both side ........ r3301 | danydb | 2010-06-15 23:57:55 +0200 (Tue, 15 Jun 2010) | 1 line Add bank CBC on line ........ r3302 | danydb | 2010-06-16 00:30:47 +0200 (Wed, 16 Jun 2010) | 2 lines Bug fix : when using a predefined operation, javascript for adding rows doesn't work properly ........
236 lines
6.9 KiB
PHP
236 lines
6.9 KiB
PHP
<?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 definition of Pre_operation
|
|
*/
|
|
|
|
/*! \brief manage the predefined operation, link to the table op_def
|
|
* and op_def_detail
|
|
*
|
|
*/
|
|
require_once("class_iselect.php");
|
|
require_once("class_ihidden.php");
|
|
class Pre_operation
|
|
{
|
|
var $db; /*!< $db database connection */
|
|
var $nb_item; /*!< $nb_item nb of item */
|
|
var $p_jrn; /*!< $p_jrn jrn_def_id */
|
|
var $jrn_type; /*!< $jrn_type */
|
|
var $name; /*!< $name name of the predef. operation */
|
|
|
|
function Pre_operation($cn) {
|
|
$this->db=$cn;
|
|
$this->od_direct='false';
|
|
}
|
|
/*!\brief fill the object with the $_POST variable */
|
|
function get_post() {
|
|
$this->nb_item=$_POST['nb_item'];
|
|
$this->p_jrn=$_REQUEST['p_jrn'];
|
|
$this->jrn_type=$_POST['jrn_type'];
|
|
$this->name=(isset($_POST['e_comm']))?$_POST['e_comm']:"";
|
|
if ( $this->name=="") {
|
|
$n=$this->db->get_next_seq('op_def_op_seq');
|
|
$this->name=$this->jrn_type.$n;
|
|
// common value
|
|
}
|
|
}
|
|
function delete () {
|
|
$sql="delete from op_predef where od_id=".$this->od_id.
|
|
" and od_direct ='".$this->od_direct."'";
|
|
$this->db->exec_sql($sql);
|
|
}
|
|
/*!\brief save the predef check first is the name is unique
|
|
* \return true op.success otherwise false
|
|
*/
|
|
function save() {
|
|
if ( $this->db->count_sql("select * from op_predef ".
|
|
"where upper(od_name)=upper('".Database::escape_string($this->name)."')".
|
|
"and jrn_def_id=".$this->p_jrn)
|
|
!= 0 )
|
|
{
|
|
echo "Cette opération a déjà été sauvée";
|
|
return false;
|
|
}
|
|
if ( $this->count() > 20 ){
|
|
echo '<h2 class="info">Vous avez atteint le max. d\'opération prédéfinie, désolé</h2>';
|
|
return false;
|
|
}
|
|
$sql=sprintf('insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct)'.
|
|
'values'.
|
|
"(%d,'%s',%d,'%s','%s')",
|
|
$this->p_jrn,
|
|
Database::escape_string($this->name),
|
|
$this->nb_item,
|
|
$this->jrn_type,
|
|
$this->od_direct);
|
|
$this->db->exec_sql($sql);
|
|
$this->od_id=$this->db->get_current_seq('op_def_op_seq');
|
|
return true;
|
|
}
|
|
/*!\brief load the data from the database and return an array
|
|
* \return an array
|
|
*/
|
|
function load() {
|
|
$sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type".
|
|
" from op_predef where od_id=".$this->od_id.
|
|
" and od_direct='".$this->od_direct."'".
|
|
" order by od_name";
|
|
$res=$this->db->exec_sql($sql);
|
|
$array=Database::fetch_all($res);
|
|
|
|
return $array;
|
|
}
|
|
function compute_array() {
|
|
$p_array=$this->load();
|
|
$array=array(
|
|
"e_comm"=>$p_array[0]["od_name"],
|
|
"nb_item"=>(($p_array[0]["od_item"]<10?10:$p_array[0]["od_item"])) ,
|
|
"p_jrn"=>$p_array[0]["jrn_def_id"],
|
|
"jrn_type"=>$p_array[0]["od_jrn_type"]
|
|
);
|
|
return $array;
|
|
|
|
}
|
|
|
|
/*!\brief show the button for selecting a predefined operation */
|
|
function show_button() {
|
|
|
|
$select=new ISelect();
|
|
$value=$this->db->make_array("select od_id,od_name from op_predef ".
|
|
" where jrn_def_id=".$this->p_jrn.
|
|
" and od_direct ='".$this->od_direct."'".
|
|
" order by od_name");
|
|
|
|
if ( empty($value)==true) return "";
|
|
$select->value=$value;
|
|
$r=$select->input("pre_def");
|
|
|
|
return $r;
|
|
}
|
|
/*!\brief count the number of pred operation for a ledger */
|
|
function count() {
|
|
$a=$this->db->count_sql("select od_id,od_name from op_predef ".
|
|
" where jrn_def_id=".$this->p_jrn.
|
|
" and od_direct ='".$this->od_direct."'".
|
|
" order by od_name");
|
|
return $a;
|
|
}
|
|
/*!\brief get the list of the predef. operation of a ledger
|
|
* \return string
|
|
*/
|
|
function get_list_ledger() {
|
|
$sql="select od_id,od_name from op_predef ".
|
|
" where jrn_def_id=".$this->p_jrn.
|
|
" and od_direct ='".$this->od_direct."'".
|
|
" order by od_name";
|
|
$res=$this->db->exec_sql($sql);
|
|
$all=Database::fetch_all($res);
|
|
return $all;
|
|
}
|
|
/*!\brief set the ledger
|
|
* \param $p_jrn is the ledger (jrn_id)
|
|
*/
|
|
function set_jrn($p_jrn) {
|
|
$this->p_jrn=$p_jrn;
|
|
}
|
|
}
|
|
|
|
/*!\brief mother of the pre_op_XXX, it contains only one data : an
|
|
* object Pre_Operation. The child class contains an array of
|
|
* Pre_Operation object
|
|
*/
|
|
class Pre_operation_detail {
|
|
var $operation;
|
|
function __construct($p_cn) {
|
|
$this->db=$p_cn;
|
|
$this->operation=new Pre_operation($this->db);
|
|
$this->valid=array('ledger'=>'jrn_def_id','ledger_type'=>'jrn_type','direct'=>'od_direct');
|
|
|
|
}
|
|
|
|
|
|
/*!\brief show a form to use pre_op
|
|
*/
|
|
function form_get () {
|
|
|
|
$hid=new IHidden();
|
|
$r=$hid->input("action","use_opd");
|
|
$r.=dossier::hidden();
|
|
$r.=$hid->input("p_jrn",$this->get("ledger"));
|
|
$r.=$hid->input("jrn_type",$this->get("ledger_type"));
|
|
if ($this->count() != 0 ) {
|
|
$r.= HtmlInput::submit('use_opd','Utilisez une op.prédéfinie');
|
|
$r.= $this->show_button();
|
|
}
|
|
return $r;
|
|
|
|
}
|
|
/*!\brief count the number of pred operation for a ledger */
|
|
function count() {
|
|
$a=$this->db->count_sql("select od_id,od_name from op_predef ".
|
|
" where jrn_def_id=".$this->jrn_def_id.
|
|
" and od_direct ='".$this->od_direct."'".
|
|
" order by od_name");
|
|
return $a;
|
|
}
|
|
/*!\brief show the button for selecting a predefined operation */
|
|
function show_button() {
|
|
|
|
$select=new ISelect();
|
|
|
|
$value=$this->get_operation();
|
|
// if ( empty($value)==true) return "";
|
|
$select->value=$value;
|
|
$r=$select->input("pre_def");
|
|
return $r;
|
|
}
|
|
public function get_operation() {
|
|
$value=$this->db->make_array("select od_id,od_name from op_predef ".
|
|
" where jrn_def_id=".FormatString($this->jrn_def_id).
|
|
" and od_direct ='".FormatString($this->od_direct)."'".
|
|
" order by od_name");
|
|
return $value;
|
|
}
|
|
function set($p_param,$value) {
|
|
if ( ! isset ($this->valid[$p_param] ) ) {
|
|
echo(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__);
|
|
exit();
|
|
}
|
|
$attr=$this->valid[$p_param];
|
|
$this->$attr=$value;
|
|
}
|
|
function get($p_param) {
|
|
|
|
if ( ! isset ($this->valid[$p_param] ) ) {
|
|
echo(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__);
|
|
exit();
|
|
}
|
|
$attr=$this->valid[$p_param];
|
|
return $this->$attr;
|
|
}
|
|
|
|
function get_post() {
|
|
$this->operation->get_post();
|
|
}
|
|
|
|
}
|