Add description to the predefined operation

This commit is contained in:
Dany De Bontridder 2013-10-01 14:12:44 +00:00
parent ca115d0065
commit 8d1dea9c07
8 changed files with 62 additions and 37 deletions

View file

@ -38,6 +38,13 @@ $name = new IText('opd_name');
$name->value = $op->od_name;
$name->size = 60;
echo "Nom =" . $name->input();
$opd_description=new ITextarea('od_description');
$opd_description->style=' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
$opd_description->value=$op->od_description;
echo '<p>';
echo "Description (max 50 car.)";
echo $opd_description->input();
echo '</p>';
echo dossier::hidden() . HtmlInput::hidden('od_id', $_GET['id']);
echo "<hr>";
//////////////////////////////////////////////////////////////////////////////

View file

@ -2090,8 +2090,7 @@ class Acc_Ledger extends jrn_def_sql
$this->internal = $internal;
// Save now the predef op
//------------------------
if (isset($opd_save))
{
if (isset ($opd_name)){
$opd = new Pre_Op_Advanced($this->db);
$opd->get_post();
$opd->save();

View file

@ -128,7 +128,9 @@ class Pre_op_ach extends Pre_operation_detail
}
return $array;
}
/*!\brief load the data from the database and return an array
/**
* @brief
* load the data from the database and return an array
* \return an array
*/
function load()
@ -146,7 +148,7 @@ class Pre_op_ach extends Pre_operation_detail
}
function display($p_array)
{
require_once('class_acc_ledger_purchase.php');
require_once('class_acc_ledger_purchase.php');
global $g_parameter,$g_user;
extract($p_array);
$ledger=new Acc_Ledger_Purchase($this->db,$this->jrn_def_id);

View file

@ -47,17 +47,38 @@ class Pre_operation
$this->od_direct='false';
$this->od_id=$p_id;
}
/**
* @brief Propose to save the operation into a predefined operation
* @return HTML string
*/
static function save_propose() {
$r="<h2>Modèle d'opération</h2>";
$r.= '<p class="decale">';
$r.= "Donnez un nom pour sauver cette opération comme modèle <br>";
$opd_name = new IText('opd_name');
$r.= "Nom du modèle " . $opd_name->input();
$opd_description=new ITextarea('od_description');
$opd_description->style=' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
$r.='</p>';
$r.= '<p class="decale">';
$r.= 'Description (max 50 car.)';
$r.='<br>';
$r.=$opd_description->input();
$r.='</p>';
return $r;
}
/*!\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=$_POST['opd_name'];
$this->name=(trim($this->name)=='')?$_POST['e_comm']:$this->name;
$this->description= $_POST['od_description'];
if ( $this->name=="")
{
$n=$this->db->get_next_seq('op_def_op_seq');
@ -89,15 +110,16 @@ class Pre_operation
echo '<span class="notice">Vous avez atteint le max. d\'op&eacute;ration pr&eacute;d&eacute;finie, d&eacute;sol&eacute;</span>';
return false;
}
$sql=sprintf('insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct)'.
$sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description)'.
'values'.
"(%d,'%s',%d,'%s','%s')",
$this->p_jrn,
Database::escape_string($this->name),
"($1,$2,$3,$4,$5 ,$6 )";
$this->db->exec_sql($sql,array($this->p_jrn,
$this->name,
$this->nb_item,
$this->jrn_type,
$this->od_direct);
$this->db->exec_sql($sql);
$this->od_direct,
$this->description,
));
$this->od_id=$this->db->get_current_seq('op_def_op_seq');
return true;
}
@ -106,12 +128,12 @@ class Pre_operation
*/
function load()
{
$sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type".
$sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description".
" from op_predef where od_id=".$this->od_id.
" order by od_name";
$res=$this->db->exec_sql($sql);
$array=Database::fetch_all($res);
foreach (array('jrn_def_id','od_name','od_item','od_jrn_type') as $field) {
foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
$this->$field=$array[0][$field];
}
switch ($this->od_jrn_type) {
@ -139,7 +161,8 @@ class Pre_operation
"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"]
"jrn_type"=>$p_array[0]["od_jrn_type"],
"od_description"=>$p_array['0']['od_description']
);
return $array;
@ -175,7 +198,7 @@ class Pre_operation
*/
function get_list_ledger()
{
$sql="select od_id,od_name from op_predef ".
$sql="select od_id,od_name,od_description from op_predef ".
" where jrn_def_id=".$this->p_jrn.
" and od_direct ='".$this->od_direct."'".
" order by od_name";
@ -246,7 +269,15 @@ class Pre_operation_detail
/*!\brief show the button for selecting a predefined operation */
function show_button($p_url)
{
$value=$this->get_operation();
$value=$this->db->get_array("select od_id,od_name,od_description from op_predef ".
" where jrn_def_id=$1".
" and od_direct =$2".
" order by od_name",array($this->jrn_def_id,$this->od_direct ));
if ( $this->jrn_def_id=='') $value=array();
$r="";
$r.='<h2>Choississez un modèle</h2>';
$r.='Filtrer '.HtmlInput::filter_table('modele_op_tab', '0', '0');
@ -254,8 +285,9 @@ class Pre_operation_detail
for ($i=0;$i<count($value);$i++) {
$r.='<tr class="'.(($i%2==0)?"even":"odd").'">';
$r.='<td>';
$r.=sprintf('<a href="%s&pre_def=%s" onclick="waiting_box()">%s</a>',$p_url,$value[$i]['value'],$value[$i]['label']);
$r.=sprintf('<a href="%s&pre_def=%s" onclick="waiting_box()">%s</a> ',$p_url,$value[$i]['od_id'],$value[$i]['od_name']);
$r.='</td>';
$r.='<td>'.h($value[$i]['od_description']).'</td>';
$r.='</tr>';
}
$r.='</table>';

View file

@ -73,12 +73,7 @@ if (isset($_POST['view_invoice']))
echo HtmlInput::hidden('ac', $_REQUEST['ac']);
echo '<div style="clear:both">';
echo "<h2>Modèle d'opération</h2>";
echo '<p class="decale">';
echo "Donnez un nom pour sauver cette opération comme modèle <br>";
$opd_name = new IText('opd_name');
echo "Nom du modèle " . $opd_name->input();
echo '</p>';
echo Pre_operation::save_propose();
echo '</div>';
echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
echo HtmlInput::submit('correct', _("Corriger"));

View file

@ -81,12 +81,7 @@ global $g_parameter;
echo HtmlInput::hidden('ac',$_REQUEST['ac']);
echo '<div style="clear:both">';
echo "<h2>Modèle d'opération</h2>";
echo '<p class="decale">';
echo "Donnez un nom pour sauver cette opération comme modèle <br>";
$opd_name=new IText('opd_name');
echo "Nom du modèle ".$opd_name->input();
echo '</p>';
echo Pre_operation::save_propose();
echo '</div>';
echo HtmlInput::hidden('ac',$_REQUEST['ac']);
echo HtmlInput::submit("record",_("Enregistrement"),'onClick="return verify_ca(\'\');"');

View file

@ -39,13 +39,7 @@ echo HtmlInput::request_to_hidden(array('ac'));
echo $ledger->confirm($_POST,false);
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 Pre_operation::save_propose();
echo '<hr>';
echo HtmlInput::submit("save","Confirmer");
echo HtmlInput::submit("correct","Corriger");

View file

@ -88,6 +88,7 @@ if ( $sa == 'jrn' )
$count++;
echo '<td>'.h($row['od_name']).'</td>';
echo '<td>'.h($row['od_description']).'</td>';
echo '<td>';
echo '<form method="POST" style="margin:0;padding:0">';
echo dossier::hidden();