0000610: Type de document : modification Libellé, Préfixe et séquence
This commit is contained in:
parent
cfea892af7
commit
003533b044
4 changed files with 159 additions and 72 deletions
|
|
@ -42,6 +42,7 @@ content[11]="ATTENTION si le poste comptable est vide, il sera créé automatiq
|
|||
content[12]="Document généré uniquement si le mode de paiement est utilisé";
|
||||
content[13]="Vous pouvez utiliser le % pour indiquer le poste parent";
|
||||
content[14]="Attention, le poste comptable doit exister, il ne sera pas vérifié";
|
||||
content[15]="Laissez à 0 pour ne rien changer";
|
||||
|
||||
function showBulle(p_ctl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,6 +33,20 @@ if ( isset($_POST['add']) )
|
|||
$catDoc=new Document_Type($cn);
|
||||
$catDoc->insert($_POST['cat'],$_POST['prefix']);
|
||||
}
|
||||
if ( isset($_POST['save'])) {
|
||||
$catDoc=new Document_Type($cn,$_POST['dt_id']);
|
||||
$catDoc->get();
|
||||
$catDoc->dt_value=trim($_POST['dt_name']);
|
||||
$catDoc->dt_prefix=trim($_POST['dt_prefix']);
|
||||
if ( $catDoc->dt_value=="") {
|
||||
alert(_("Le nom ne peut pas être vide"));
|
||||
} else {
|
||||
$catDoc->update();
|
||||
}
|
||||
if ($_POST['seq'] != 0 && isNumber($_POST['seq'])==1){
|
||||
$catDoc->set_number($_POST['seq']);
|
||||
}
|
||||
}
|
||||
$aList=Document_Type::get_list($cn);
|
||||
$addCat=new IText('cat');
|
||||
$addPrefix=new IText('prefix');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
|
|
@ -15,87 +16,124 @@
|
|||
* 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
|
||||
/* ! \file
|
||||
* \brief class for the table document_type
|
||||
*/
|
||||
|
||||
/*! \brief class for the table document_type
|
||||
*< dt_id pk document_type
|
||||
*< dt_value value
|
||||
/* ! \brief class for the table document_type
|
||||
* < dt_id pk document_type
|
||||
* < dt_value value
|
||||
*/
|
||||
class Document_type
|
||||
{
|
||||
/*! document_type
|
||||
* \brief constructor
|
||||
* \param $p_cn database connx
|
||||
*/
|
||||
function document_type($p_cn)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
$this->dt_id=-1;
|
||||
}
|
||||
/*!
|
||||
* \brief Get all the data for this dt_id
|
||||
*/
|
||||
function get()
|
||||
{
|
||||
$sql="select * from document_type where dt_id=$1";
|
||||
$R=$this->db->exec_sql($sql,array($this->dt_id));
|
||||
$r=Database::fetch_array($R,0);
|
||||
$this->dt_id=$r['dt_id'];
|
||||
$this->dt_value=$r['dt_value'];
|
||||
}
|
||||
/**
|
||||
*@brief get a list
|
||||
*@parameter $p_cn database connection
|
||||
*@return array of data from document_type
|
||||
*/
|
||||
static function get_list($p_cn)
|
||||
{
|
||||
$sql="select * from document_type order by dt_value";
|
||||
$r=$p_cn->get_array($sql);
|
||||
$array=array();
|
||||
for ($i=0;$i<count($r);$i++)
|
||||
{
|
||||
$tmp['dt_value']=$r[$i]['dt_value'];
|
||||
$tmp['dt_prefix']=$r[$i]['dt_prefix'];
|
||||
/* ! document_type
|
||||
* \brief constructor
|
||||
* \param $p_cn database connx
|
||||
*/
|
||||
|
||||
$bt=new IButton('X'.$r[$i]['dt_id']);
|
||||
$bt->label=_('Modifier');
|
||||
$bt->javascript="cat_doc_change('".$r[$i]['dt_id']."','".Dossier::id()."');";
|
||||
function document_type($p_cn, $p_id = -1)
|
||||
{
|
||||
$this->db = $p_cn;
|
||||
$this->dt_id = $p_id;
|
||||
}
|
||||
|
||||
$tmp['js_mod']=$bt->input();
|
||||
$tmp['dt_id']=$r[$i]['dt_id'];
|
||||
/* !
|
||||
* \brief Get all the data for this dt_id
|
||||
*/
|
||||
|
||||
$bt=new IButton('X'.$r[$i]['dt_id']);
|
||||
$bt->label=_('Effacer');
|
||||
$bt->javascript="if (confirm('"._('Vous confirmez')."')==true) {";
|
||||
$bt->javascript.="cat_doc_remove('".$r[$i]['dt_id']."','".Dossier::id()."');";
|
||||
$bt->javascript.='}';
|
||||
|
||||
$tmp['js_remove']=$bt->input();
|
||||
function get()
|
||||
{
|
||||
$sql = "select * from document_type where dt_id=$1";
|
||||
$R = $this->db->exec_sql($sql, array($this->dt_id));
|
||||
if (count($R) == 0) return 1;
|
||||
$r = Database::fetch_array($R, 0);
|
||||
$this->dt_id = $r['dt_id'];
|
||||
$this->dt_value = $r['dt_value'];
|
||||
$this->dt_prefix = $r['dt_prefix'];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get a list
|
||||
* @parameter $p_cn database connection
|
||||
* @return array of data from document_type
|
||||
*/
|
||||
static function get_list($p_cn)
|
||||
{
|
||||
$sql = "select * from document_type order by dt_value";
|
||||
$r = $p_cn->get_array($sql);
|
||||
$array = array();
|
||||
for ($i = 0; $i < count($r); $i++)
|
||||
{
|
||||
$tmp['dt_value'] = $r[$i]['dt_value'];
|
||||
$tmp['dt_prefix'] = $r[$i]['dt_prefix'];
|
||||
|
||||
$bt = new IButton('X' . $r[$i]['dt_id']);
|
||||
$bt->label = _('Modifier');
|
||||
$bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
|
||||
|
||||
$tmp['js_mod'] = $bt->input();
|
||||
$tmp['dt_id'] = $r[$i]['dt_id'];
|
||||
|
||||
$bt = new IButton('X' . $r[$i]['dt_id']);
|
||||
$bt->label = _('Effacer');
|
||||
$bt->javascript = "if (confirm('" . _('Vous confirmez') . "')==true) {";
|
||||
$bt->javascript.="cat_doc_remove('" . $r[$i]['dt_id'] . "','" . Dossier::id() . "');";
|
||||
$bt->javascript.='}';
|
||||
|
||||
$tmp['js_remove'] = $bt->input();
|
||||
|
||||
|
||||
$array[$i]=$tmp;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
function insert($p_value,$p_prefix)
|
||||
{
|
||||
$sql="insert into document_type(dt_value,dt_prefix) values ($1,$2)";
|
||||
try
|
||||
{
|
||||
if( $this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))',array($p_value))>0)
|
||||
throw new Exception('Nom en double');
|
||||
if ( strlen(trim($p_value))>0)
|
||||
$this->db->exec_sql($sql,array($p_value,$p_prefix));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
alert(j(_("Impossible d'ajouter [$p_value] ").$e->getMessage()));
|
||||
}
|
||||
}
|
||||
$array[$i] = $tmp;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function insert($p_value, $p_prefix)
|
||||
{
|
||||
$sql = "insert into document_type(dt_value,dt_prefix) values ($1,$2)";
|
||||
try
|
||||
{
|
||||
if ($this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))', array($p_value)) > 0)
|
||||
throw new Exception('Nom en double');
|
||||
if (strlen(trim($p_value)) > 0)
|
||||
$this->db->exec_sql($sql, array($p_value, $p_prefix));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
alert(j(_("Impossible d'ajouter [$p_value] ") . $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->db->exec_sql("update document_type set dt_value=$1,dt_prefix=$2 where dt_id=$3", array($this->dt_value,
|
||||
$this->dt_prefix, $this->dt_id));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
alert(" Erreur " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function set_number($p_int)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->db->exec_sql("alter sequence seq_doc_type_" . $this->dt_id . " restart " . $p_int);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
alert("Erreur " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,21 @@
|
|||
*/
|
||||
require_once 'class_document_type.php';
|
||||
echo HtmlInput::title_box(_('Type de document'),'change_doc_div');
|
||||
|
||||
$doc_type=new Document_type($cn,$dt_id);
|
||||
$doc_type->get();
|
||||
?>
|
||||
<form method="GET" id="cat_doc_f" onsubmit="cat_doc_change_record('cat_doc_f');">
|
||||
<form method="POST" id="cat_doc_f" onsubmit="cat_doc_change_record('cat_doc_f');">
|
||||
<?=HtmlInput::request_to_hidden(array("ac","gDossier","dt_id"))?>
|
||||
<table>
|
||||
<tr>
|
||||
<td> <?=_('Nom')?>
|
||||
</td>
|
||||
<td>
|
||||
<?
|
||||
$name=new IText('dt_name',$doc_type->dt_value);
|
||||
echo $name->input();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
@ -37,13 +45,39 @@ echo HtmlInput::title_box(_('Type de document'),'change_doc_div');
|
|||
<td><?=_('Préfixe')?>
|
||||
</td>
|
||||
<td>
|
||||
<?
|
||||
$prefix=new IText('dt_prefix',$doc_type->dt_prefix);
|
||||
echo $prefix->input();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?=_('Prochain numéro')?>
|
||||
<td><?=_('numéro actuel')?>
|
||||
</td>
|
||||
<td>
|
||||
<?
|
||||
$ret= $cn->get_array("select last_value,is_called from seq_doc_type_".$doc_type->dt_id) ;
|
||||
|
||||
$last=$ret[0]['last_value'];
|
||||
/*!
|
||||
*\note With PSQL sequence , the last_value column is 1 when before AND after the first call, to make the difference between them
|
||||
* I have to check whether the sequence has been already called or not */
|
||||
if ($ret[0]['is_called']=='f' ) $last--;
|
||||
echo $last;
|
||||
?>
|
||||
</td>
|
||||
<tr>
|
||||
<td><?=_('Prochain numéro')?>
|
||||
<?=
|
||||
HtmlInput::infobulle(15);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?
|
||||
$seq=new INum('seq',0);
|
||||
echo $seq->input();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue