Rewriting of Predefined Operation. You can add new Predefined Operation

This commit is contained in:
Dany De Bontridder 2020-09-29 18:08:26 +02:00
parent 298121f999
commit dee33b561f
13 changed files with 194 additions and 54 deletions

View file

@ -2433,4 +2433,11 @@ span.title_tab_row {
background-color: #000066 !important;
color : white !important;
}
}
/**
* dialog box for adding, modifying predefined operation
*/
#prdfop {
}

View file

@ -2469,3 +2469,9 @@ span.title_tab_row {
color : white !important;
}
/**
* dialog box for adding, modifying predefined operation
*/
#prdfop {
}

View file

@ -177,7 +177,9 @@ td.tool a.mtitle:hover {
width: 100%;
}
@media only screen and (max-width:955px) {
margin-bottom: 70px;
body {
margin-bottom: 70px;
}
}
#module {
@ -953,7 +955,7 @@ background: -webkit-linear-gradient(top, rgba(109,179,242,1) 0%,rgba(84,163,238,
background: -o-linear-gradient(top, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* IE6-9 */ilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#001e5799', endColorstr='#001e5799',GradientType=0 ); /* IE6-9 */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* IE6-9 */filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#001e5799', endColorstr='#001e5799',GradientType=0 ); /* IE6-9 */
}
td.tool {
@ -2141,7 +2143,7 @@ td.selectedmenu {
*/
#summary_op1,#summary_op2
{
position:float;
float:left;
}
/*
@ -2365,4 +2367,11 @@ span.title_tab_row {
background-color: #000066 !important;
color : white !important;
}
}
/**
* dialog box for adding, modifying predefined operation
*/
#prdfop {
}

View file

@ -56,14 +56,13 @@ $operation_predef_mtable->set_callback("ajax_misc.php");
if ($action=="input")
{
if ($p_id == -1 ) {
// new operation to insert
if ($p_id < 0 ) {
} else {
// display existing operation for updating
header('Content-type: text/xml; charset=UTF-8');
echo $operation_predef_mtable->ajax_input()->saveXML();
$operation_predef_mtable->set_force_ledger_type($p_id);
}
// display existing operation for updating
header('Content-type: text/xml; charset=UTF-8');
echo $operation_predef_mtable->ajax_input()->saveXML();
return;
}
elseif ($action == "save")

View file

@ -45,15 +45,15 @@ foreach (array('l','t','d','gDossier') as $a)
}
$cn=Dossier::connect();
$op=new Pre_operation_detail($cn);
$op->set('ledger',$l);
$op->set('ledger_type',$t);
$op->set('direct',$d);
$op=new Pre_operation($cn);
$op->set_p_jrn($l);
$op->set_jrn_type($t);
$op->set_od_direct($d);
$url=http_build_query(array('action'=>'use_opd','p_jrn_predef'=>$l,'ac'=>$_GET['ac'],'gDossier'=>dossier::id()));
$html="";
$html.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n");
$html.=$op->show_button('do.php?'.$url);
$html.=$op->display_list_operation('do.php?'.$url);
$html.=' <p style="text-align: center">'.
HtmlInput::button_hide('modele_op_div').
'</p>';

View file

@ -27,10 +27,13 @@
require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
require_once NOALYSS_INCLUDE."/database/op_predef_sql.class.php";
require_once NOALYSS_INCLUDE."/class/pre_operation.class.php";
require_once NOALYSS_INCLUDE."/lib/select_box.class.php";
class Operation_Predef_MTable extends Manage_Table_SQL
{
private $pre_operation;
private $force_ledger_type; //!< When adding , the ledger must be set
function __construct(Op_predef_SQL $p_table)
{
parent::__construct($p_table);
@ -45,7 +48,8 @@ class Operation_Predef_MTable extends Manage_Table_SQL
$aLedger=$p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def order by jrn_def_name asc");
$this->set_sort_column("jrn_def_id");
$this->set_sort_column("od_name");
$this->set_col_sort(1);
$this->set_order(array("jrn_def_id","od_name","od_description","od_jrn_type"));
$this->set_col_type("jrn_def_id","select",$aLedger);
@ -53,7 +57,30 @@ class Operation_Predef_MTable extends Manage_Table_SQL
$this->set_property_updatable("jrn_def_id",false);
$this->set_property_updatable("od_jrn_type",false);
$this->pre_operation=null;
// create our own "Append button"
$this->set_append_row(false);
$this->set_dialog_box("prdfop");
$this->set_dialogbox_style(["position"=>"absolute","top"=>"5%","width:auto","min-width"=>"80%"]);
}
/**
* @return mixed
*/
public function get_force_ledger_type()
{
return $this->force_ledger_type;
}
/**
* When adding the ledger_type must be set
* if p_id == -2 then type ACH , 3 for VEN and 4 for ODS
* @param mixed $force_ledger_type
*/
public function set_force_ledger_type($force_ledger_type)
{
$aLedger=array(-2=>'ACH',-3=>'VEN',-4=>'ODS');
$this->force_ledger_type = $aLedger[$force_ledger_type];
return $this;
}
/**
@ -63,9 +90,20 @@ class Operation_Predef_MTable extends Manage_Table_SQL
function input()
{
$obj=$this->get_table();
$this->pre_operation = new Pre_operation($obj->cn);
$this->pre_operation->set_od_id($obj->get("od_id"));
$this->pre_operation->display();
$od_id=$obj->get("od_id");
if ($od_id > 0 ) {
$this->pre_operation = new Pre_operation($obj->cn);
$this->pre_operation->set_od_id($obj->get("od_id"));
$this->pre_operation->display();
} else {
// display blanck operation type ledger = ACH
$this->pre_operation = new Pre_operation($obj->cn);
// new operation od_id = -1
$this->pre_operation->set_od_id(-1);
$this->pre_operation->set_jrn_type($this->get_force_ledger_type());
$this->pre_operation->display();
}
}
/**
@ -114,7 +152,27 @@ class Operation_Predef_MTable extends Manage_Table_SQL
function save()
{
$this->pre_operation->save();
$this->set_pk($this->pre_operation->get_od_id());
}
/**
* Display a button to choose a type of operation and call a dialog box for adding
*/
function display_button_add()
{
$select=new Select_Box(uniqid(),_("Ajout"));
$select->set_position('in-absolute');
$select->add_javascript(_("Achat"),sprintf("%s.input('-2','%s')",
$this->get_object_name(),
$this->get_object_name(), "xx", "smallbutton", BUTTONADD));
$select->add_javascript(_("Vente"),sprintf("%s.input('-3','%s')",
$this->get_object_name(),
$this->get_object_name(), "xx", "smallbutton", BUTTONADD));
$select->add_javascript(_("Opérations Diverses"),sprintf("%s.input('-4','%s')",
$this->get_object_name(),
$this->get_object_name(), "xx", "smallbutton", BUTTONADD));
echo $select->input();
}
}

View file

@ -33,7 +33,10 @@ class Pre_op_ach extends Pre_operation_detail
{
parent::__construct($cn);
}
/**
* @brief get the post and stove them into data member , before saving them in the db
* @see save
*/
function get_post()
{
$http = new \HttpInput();
@ -100,8 +103,11 @@ class Pre_op_ach extends Pre_operation_detail
throw $e;
}
}
/*!\brief compute an array accordingly with the FormVenView function
/**
* @brief compute an array accordingly with the FormVenView function, first the data is fetched (via load)
* to the database and turns into an array to be use with Pre_Op_Ach::display
* @return an array for filling the form
* @see load
*/
function compute_array($p_od_id)
{
@ -144,10 +150,20 @@ class Pre_op_ach extends Pre_operation_detail
" opd_quantity , opd_comment,opd_tva_amount from op_predef_detail where od_id= $1 ".
" order by opd_id";
$res=$this->db->exec_sql($sql,[$p_od_id]);
if ($res == false) return array();
$array=Database::fetch_all($res);
return $array;
}
/**
* Display the form for modifying or adding new predefined operation
* @param array $p_array is the result of compute_array or blank
* @return string containing HTML code of the form
* @throws Exception
* @see compute_array
* @see load
*
*/
function display($p_array)
{
require_once NOALYSS_INCLUDE.'/class/acc_ledger_purchase.class.php';
@ -184,8 +200,6 @@ class Pre_op_ach extends Pre_operation_detail
$f_legend=_('En-tête facture fournisseur');
/* if we suggest the next pj, then we need a javascript */
// Display the customer
//--
$fiche='deb';
@ -393,6 +407,5 @@ class Pre_op_ach extends Pre_operation_detail
return $r;
return $r;
}
}

View file

@ -33,6 +33,10 @@ class Pre_Op_Advanced extends Pre_operation_detail
{
parent::__construct($cn);
}
/**
* @brief get the post and stove them into data member , before saving them in the db
* @see save
*/
function get_post()
{
$http = new \HttpInput();
@ -143,13 +147,24 @@ class Pre_Op_Advanced extends Pre_operation_detail
" order by opd_id";
$res=$this->db->exec_sql($sql,[$p_od_id]);
$array=Database::fetch_all($res);
if ($array == false ) return array();
return $array;
}
/**
* Display the form for modifying or adding new predefined operation
* @param array $p_array is the result of compute_array or blank
* @return string containing HTML code of the form
* @throws Exception
* @see compute_array
* @see load
*
*/
function display($p_array)
{
global $g_parameter, $g_user;
require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
$legder=new Acc_Ledger($this->db,$p_array['p_jrn']);
$legder->nb=$legder->get_min_row();
$add_js = "";
@ -169,12 +184,11 @@ class Pre_Op_Advanced extends Pre_operation_detail
$nb_row = (isset($p_array['nb_item']) ) ? $p_array['nb_item' ]: $legder->nb;
$ret.=HtmlInput::hidden('nb_item', $nb_row);
$ret.=HtmlInput::hidden('p_jrn', $p_array['p_jrn']);
$ret.=dossier::hidden();
$ret.=dossier::hidden();
$ret.=HtmlInput::hidden('jrn_type', $legder->get_type());
$ret.=HtmlInput::hidden('jrn_type', "ODS");
$info = Icon_Action::infobulle(0);
$info_poste = Icon_Action::infobulle(9);
if ($g_user->check_action(FICADD) == 1)

View file

@ -34,7 +34,10 @@ class Pre_op_ven extends Pre_operation_detail
{
parent::__construct($cn);
}
/**
* @brief get the post and stove them into data member , before saving them in the db
* @see save
*/
function get_post()
{
$http=new \HttpInput();
@ -144,13 +147,18 @@ class Pre_op_ven extends Pre_operation_detail
" order by opd_id";
$res=$this->db->exec_sql($sql,[$p_od_id]);
$array=Database::fetch_all($res);
if ($res == false) return array();
return $array;
}
/**
* @param array $p_array
* @return string
* Display the form for modifying or adding new predefined operation
* @param array $p_array is the result of compute_array or blank
* @return string containing HTML code of the form
* @throws Exception
* @see compute_array
* @see load
*
*/
function display($p_array)
{
@ -158,7 +166,6 @@ class Pre_op_ven extends Pre_operation_detail
require_once NOALYSS_INCLUDE.'/class/acc_ledger_sold.class.php';
$ledger=new Acc_Ledger_Sold($this->db,$p_array['p_jrn']);
$flag_tva=$g_parameter->MY_TVA_USE;
/* Add button */
$f_add_button=new IButton('add_card');

View file

@ -162,20 +162,19 @@ class Pre_operation
}
try {
$this->db->start();
$sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description)'.
'values'.
"($1,$2,$3,$4,$5 ,$6 )";
$this->db->exec_sql($sql,array($this->p_jrn,
$sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description) '.
' values '.
"($1,$2,$3,$4,$5 ,$6)".
'returning od_id';
$this->od_id= $this->db->get_value($sql,array($this->p_jrn,
$this->name,
$this->nb_item,
$this->jrn_type,
$this->od_direct,
$this->description,
));
$this->od_id=$this->db->get_current_seq('op_def_op_seq');
// $this->detail=Pre_operation_detail::build_detail($this->jrn_type,$this->db);
$this->detail->save($this->od_id,$this->nb_item);
$this->db->commit();
} catch (Exception $e) {
@ -215,23 +214,21 @@ class Pre_operation
* @param $p_ledger_id
* @throws Exception
*/
function blank($p_ledger_id) {
function blank() {
$array["od_id"]=-1;
$array['jrn_def_id']=$p_ledger_id;
$array['jrn_def_id']=0;
$array['od_name']="";
$array['od_item']=2;
$array['od_jrn_type']=$this->db->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",[$p_ledger_id]);
$array['od_jrn_type']=$this->get_jrn_type();
$array['od_description']="";
foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
$this->$field=$array[$field];
}
$this->od_jrn_type=$array['od_jrn_type'];
$this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
$this->detail->set_od_id(0);
$this->detail->set_jrn($p_ledger_id);
return $array;
$this->detail = Pre_operation_detail::build_detail($array['od_jrn_type'], $this->db);
$darray[0]=$array;
return $darray;
}
function compute_array()
@ -239,7 +236,7 @@ class Pre_operation
if ($this->od_id > 0) {
$p_array = $this->load();
} else {
$p_array=$this->blank($this->p_jrn);
$p_array=$this->blank();
}
$array=array(
"e_comm"=>$p_array[0]["od_name"],
@ -254,8 +251,10 @@ class Pre_operation
}
/*!\brief show the button for selecting a predefined operation */
function show_button()
/*!\brief show the button for selecting a predefined operation
@deprecated
*/
function show_button_deprecated()
{
$select=new ISelect();
@ -301,6 +300,8 @@ class Pre_operation
function display()
{
$array=$this->compute_array();
$select_ledger=$this->choose_ledger($array['jrn_type'],$array['p_jrn']);
require NOALYSS_TEMPLATE."/pre_operation_display.php";
echo $this->detail->display($array);
}
@ -408,7 +409,6 @@ class Pre_operation
public function get_jrn_type()
{
return $this->jrn_type;
return $this;
}
/**
@ -416,6 +416,7 @@ class Pre_operation
*/
public function set_jrn_type($jrn_type)
{
$jrn_type=strtoupper($jrn_type);
if ( ! in_array ($jrn_type,['ACH','FIN','VEN','ODS'] )) throw new Exception('prop03.invalid ledger type');
$this->jrn_type = $jrn_type;
return $this;
@ -503,6 +504,22 @@ class Pre_operation
$this->jrn_type=$this->db->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",[$p_jrn]);
return $this;
}
/**
* Build the select list for choosing the ledger
* @param string $p_string ledger type ACH VEN or ODS
* @param $p_default selected ledger , -1 if none
* @return ISelect
*/
function choose_ledger($p_ledger_type,$p_default) {
$select_ledger=new ISelect("p_jrn");
$select_ledger->value=$this->db->make_array("select jrn_def_id,jrn_def_name
from jrn_def where jrn_def_type=$1 order by 2",
0,
[$p_ledger_type]);
$select_ledger->selected=$p_default;
return $select_ledger;
}
}
/*!\brief mother of the pre_op_XXX, it contains only one data : an

View file

@ -35,4 +35,10 @@ $operation_predef_mtable->set_json(json_encode(array( "ac"=>$http->request("ac
"gDossier"=>Dossier::id()
)));
$operation_predef_mtable->create_js_script();
$operation_predef_mtable->display_table();
echo '<p>';
$operation_predef_mtable->display_button_add();
echo '</p>';
$operation_predef_mtable->display_table();
echo '<p>';
$operation_predef_mtable->display_button_add();
echo '</p>';

View file

@ -34,3 +34,7 @@ $description->style=' class="itextarea" style="width:30em;height:4em;vertical-al
<?php echo _('Description (max 50 car.)'); ?>
<?php echo $description->input();?>
</p>
<p>
<?php echo _("Journal") ?>
<?php echo $select_ledger->input(); ?>
</p>

View file

@ -5,13 +5,12 @@
<legend><?php echo $f_legend ?>
</legend>
<?php echo $f_type?><?php echo $f_client_qcode?><?php echo $f_client_bt?> <?php echo $f_client?><br>
<input type="hidden" id="p_jrn" name="p_jrn" value="<?php echo $p_array["p_jrn"]; ?>">
<?php echo $str_add_button?>
</fieldset>
<div class="fieldset" style="overflow:auto;max-height:300px">
<div class="fieldset">
<h1 class="fiedset"><?php echo $f_legend_detail?></h1>
<div style="">
<table id="sold_item" width="100%" border="0">
<tr>
<th style="width:auto"colspan="2">Code <?php echo Icon_Action::infobulle(0)?></th>
@ -54,6 +53,7 @@ echo '</tr>';
?>
</table>
<div style="position:float;float:right;text-align:right;padding-right:5px;font-size:1.2em;font-weight:bold;color:blue">
<?php echo HtmlInput::button('act',_('Actualiser'),'onClick="compute_all_ledger();"'); ?>
</div>
@ -79,7 +79,7 @@ echo '</tr>';
<br><?php echo _('Total')?>
<?php endif; ?>
</div>
</div>