diff --git a/include/ajax_mod_predf_op.php b/include/ajax_mod_predf_op.php index 8b341c31d..51f4c6f4e 100644 --- a/include/ajax_mod_predf_op.php +++ b/include/ajax_mod_predf_op.php @@ -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 '

'; +echo "Description (max 50 car.)"; +echo $opd_description->input(); +echo '

'; echo dossier::hidden() . HtmlInput::hidden('od_id', $_GET['id']); echo "
"; ////////////////////////////////////////////////////////////////////////////// diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 7bbac765d..521bc369f 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -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(); diff --git a/include/class_pre_op_ach.php b/include/class_pre_op_ach.php index 83bcef0fd..5a4a48ffb 100644 --- a/include/class_pre_op_ach.php +++ b/include/class_pre_op_ach.php @@ -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); diff --git a/include/class_pre_operation.php b/include/class_pre_operation.php index 403a1a13c..940222348 100644 --- a/include/class_pre_operation.php +++ b/include/class_pre_operation.php @@ -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="

Modèle d'opération

"; + $r.= '

'; + $r.= "Donnez un nom pour sauver cette opération comme modèle
"; + $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.='

'; + $r.= '

'; + $r.= 'Description (max 50 car.)'; + $r.='
'; + $r.=$opd_description->input(); + $r.='

'; + 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 'Vous avez atteint le max. d\'opération prédéfinie, désolé'; 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.='

Choississez un modèle

'; $r.='Filtrer '.HtmlInput::filter_table('modele_op_tab', '0', '0'); @@ -254,8 +285,9 @@ class Pre_operation_detail for ($i=0;$i'; $r.=''; - $r.=sprintf('%s',$p_url,$value[$i]['value'],$value[$i]['label']); + $r.=sprintf('%s ',$p_url,$value[$i]['od_id'],$value[$i]['od_name']); $r.=''; + $r.=''.h($value[$i]['od_description']).''; $r.=''; } $r.=''; diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index e4fc62bfd..d532a588b 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -73,12 +73,7 @@ if (isset($_POST['view_invoice'])) echo HtmlInput::hidden('ac', $_REQUEST['ac']); echo '
'; - echo "

Modèle d'opération

"; - echo '

'; - echo "Donnez un nom pour sauver cette opération comme modèle
"; - $opd_name = new IText('opd_name'); - echo "Nom du modèle " . $opd_name->input(); - echo '

'; + echo Pre_operation::save_propose(); echo '
'; echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"'); echo HtmlInput::submit('correct', _("Corriger")); diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index 97d9da3f7..b0870aa4a 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -81,12 +81,7 @@ global $g_parameter; echo HtmlInput::hidden('ac',$_REQUEST['ac']); echo '
'; - echo "

Modèle d'opération

"; - echo '

'; - echo "Donnez un nom pour sauver cette opération comme modèle
"; - $opd_name=new IText('opd_name'); - echo "Nom du modèle ".$opd_name->input(); - echo '

'; + echo Pre_operation::save_propose(); echo '
'; echo HtmlInput::hidden('ac',$_REQUEST['ac']); echo HtmlInput::submit("record",_("Enregistrement"),'onClick="return verify_ca(\'\');"'); diff --git a/include/operation_ods_confirm.inc.php b/include/operation_ods_confirm.inc.php index fbc101ea2..a237782a7 100644 --- a/include/operation_ods_confirm.inc.php +++ b/include/operation_ods_confirm.inc.php @@ -39,13 +39,7 @@ echo HtmlInput::request_to_hidden(array('ac')); echo $ledger->confirm($_POST,false); echo '
'; -$chk=new ICheckBox(); -$chk->selected=false; -echo $chk->input('opd_save'); -echo "Sauvez cette opération comme modèle d'opération ?"; -echo '
'; -$opd_name=new IText('opd_name'); -echo "Nom du modèle ".$opd_name->input(); +echo Pre_operation::save_propose(); echo '
'; echo HtmlInput::submit("save","Confirmer"); echo HtmlInput::submit("correct","Corriger"); diff --git a/include/preod.inc.php b/include/preod.inc.php index dacaf6153..33667e28a 100644 --- a/include/preod.inc.php +++ b/include/preod.inc.php @@ -88,6 +88,7 @@ if ( $sa == 'jrn' ) $count++; echo ''.h($row['od_name']).''; + echo ''.h($row['od_description']).''; echo ''; echo '
'; echo dossier::hidden();