Predefined Operation rewriting
This commit is contained in:
parent
4a2e3d0b8f
commit
b941d77688
19 changed files with 1063 additions and 755 deletions
|
|
@ -159,7 +159,6 @@ $path = array(
|
|||
"remove_submenu"=>"ajax_remove_submenu",
|
||||
"cardsearch"=>"ajax_boxcard_search",
|
||||
"saldo"=>"ajax_bank_saldo",
|
||||
"up_predef"=>"ajax_update_predef",
|
||||
"upd_receipt"=>"ajax_get_receipt",
|
||||
"up_pay_method"=>"ajax_update_payment",
|
||||
"openancsearch"=>"ajax_anc_search",
|
||||
|
|
|
|||
|
|
@ -26,8 +26,21 @@
|
|||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
ob_start();
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
||||
$op=new Pre_Operation($cn,$_GET['id']);
|
||||
$array=$op->load();
|
||||
$id=$http->get("id","number");
|
||||
|
||||
$op=new Pre_Operation($cn,$id);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// if id > 0 then we display an existing template operation
|
||||
// otherwise a blank one
|
||||
// -----------------------------------------------------------------
|
||||
if ( $id > 0) {
|
||||
$array = $op->load();
|
||||
} else {
|
||||
$ledger_id=$http->get("ledger_id","number");
|
||||
$op->set_jrn($ledger_id);
|
||||
$array=$op->blank($ledger_id);
|
||||
}
|
||||
echo HtmlInput::title_box(_('Modification du nom'),'mod_predf_op','close','','n');
|
||||
|
||||
echo '
|
||||
|
|
|
|||
|
|
@ -23,46 +23,52 @@
|
|||
* \brief save the new predefined operation
|
||||
* included from ajax_misc
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
|
||||
$http=new HttpInput();
|
||||
|
||||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
if ($g_user->check_module('PREDOP') == 0) exit();
|
||||
$name=$http->post("opd_name","string", "");
|
||||
if ( trim($name) != '')
|
||||
{
|
||||
try
|
||||
{
|
||||
$od_id=$http->post("od_id", "number");
|
||||
$cn->exec_sql('delete from op_predef where od_id=$1',
|
||||
array($od_id));
|
||||
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/operation_predef_mtable.class.php';
|
||||
$http=new HttpInput();
|
||||
|
||||
$cn->exec_sql("delete from op_predef_detail where od_id=$1",array($od_id));
|
||||
|
||||
$jrn_type=$http->post("jrn_type");
|
||||
switch ($jrn_type) {
|
||||
case 'ACH':
|
||||
$operation=new Pre_op_ach($cn);
|
||||
break;
|
||||
case 'VEN':
|
||||
$operation=new Pre_op_ven($cn);
|
||||
break;
|
||||
case 'ODS':
|
||||
$operation=new Pre_Op_Advanced($cn);
|
||||
break;
|
||||
default :
|
||||
throw new Exception(_('Type de journal invalide'));
|
||||
}
|
||||
$operation->get_post();
|
||||
$operation->save();
|
||||
$cn->commit();
|
||||
|
||||
}
|
||||
catch (Exception $exc)
|
||||
{
|
||||
error_log($exc->getTraceAsString());
|
||||
throw $exc;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
try {
|
||||
$table=$http->request('table');
|
||||
$action=$http->request('action');
|
||||
$p_id=$http->request('p_id', "number");
|
||||
$ctl_id=$http->request('ctl');
|
||||
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
if ( $g_user->check_module("PREDOP") == 0) die();
|
||||
|
||||
$prd_op=new Op_predef_SQL($cn);
|
||||
$prd_op->set_pk_value($p_id);
|
||||
$prd_op->load();
|
||||
|
||||
$operation_predef_mtable=new Operation_Predef_MTable($prd_op);
|
||||
|
||||
|
||||
$operation_predef_mtable->add_json_param("op","save_predf");
|
||||
$operation_predef_mtable->set_object_name($ctl_id);
|
||||
$operation_predef_mtable->set_callback("ajax_misc.php");
|
||||
|
||||
if ($action=="input")
|
||||
{
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo $operation_predef_mtable->ajax_input()->saveXML();
|
||||
return;
|
||||
}
|
||||
elseif ($action == "save")
|
||||
{
|
||||
$xml=$operation_predef_mtable->ajax_save();
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo $xml->saveXML();
|
||||
}
|
||||
elseif ($action == "delete")
|
||||
{
|
||||
$xml=$operation_predef_mtable->ajax_delete();
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo $xml->saveXML();
|
||||
}
|
||||
|
|
@ -788,10 +788,11 @@ class Acc_Ledger extends jrn_def_sql
|
|||
ob_start();
|
||||
echo '<div id="predef_form">';
|
||||
echo HtmlInput::hidden('p_jrn_predef', $this->id);
|
||||
$op=new Pre_op_ods($this->db);
|
||||
$op->set('ledger', $this->id);
|
||||
$op->set('ledger_type', "ODS");
|
||||
$op->set('direct', 't');
|
||||
$op=new Pre_operation( $this->db);
|
||||
$op->set_p_jrn($this->id);
|
||||
$op->set_jrn_type("ODS");
|
||||
$op->set_od_direct('t');
|
||||
|
||||
$url=http_build_query(
|
||||
array('action'=>'use_opd',
|
||||
'p_jrn_predef'=>$this->id,
|
||||
|
|
@ -1328,14 +1329,16 @@ class Acc_Ledger extends jrn_def_sql
|
|||
|
||||
$this->pj=$acc_end->set_pj();
|
||||
|
||||
$this->db->exec_sql("update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
$this->db->exec_sql("update jrn set jr_internal=$1
|
||||
where jr_grpt_id = $2",array($internal,$seq));
|
||||
|
||||
$this->internal=$internal;
|
||||
// Save now the predef op
|
||||
//------------------------
|
||||
if (isset($opd_name)&&trim($opd_name)!="")
|
||||
{
|
||||
$opd=new Pre_Op_Advanced($this->db);
|
||||
$opd=new Pre_operation($this->db);
|
||||
$opd->set_od_direct('t');
|
||||
$opd->get_post();
|
||||
$opd->save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1318,10 +1318,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
ob_start();
|
||||
echo '<div id="predef_form">';
|
||||
echo HtmlInput::hidden('p_jrn_predef', $this->id);
|
||||
$op = new Pre_op_ach($this->db);
|
||||
$op->set('ledger', $this->id);
|
||||
$op->set('ledger_type', "ACH");
|
||||
$op->set('direct', 'f');
|
||||
$op = new Pre_operation($this->db);
|
||||
$op->set_p_jrn($this->id);
|
||||
$op->set_jrn_type("ACH");
|
||||
$op->set_od_direct('f');
|
||||
$url=http_build_query(array('p_jrn_predef'=>$this->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
|
||||
echo $op->form_get('do.php?'.$url);
|
||||
echo '</div>';
|
||||
|
|
|
|||
|
|
@ -1310,11 +1310,12 @@ EOF;
|
|||
ob_start();
|
||||
echo '<div id="predef_form">';
|
||||
echo HtmlInput::hidden('p_jrn_predef', $this->id);
|
||||
$op=new Pre_op_ven($this->db);
|
||||
$op->set('ledger', $this->id);
|
||||
$op->set('ledger_type', "VEN");
|
||||
$op->set('direct', 'f');
|
||||
$url=http_build_query(array('p_jrn_predef'=>$this->id, 'ac'=>$_REQUEST['ac'],
|
||||
$op=new Pre_operation($this->db);
|
||||
$op->set_jrn_type("VEN");
|
||||
$op->set_p_jrn($this->id);
|
||||
$op->set_od_direct('f');
|
||||
$http=new \HttpInput();
|
||||
$url=http_build_query(array('p_jrn_predef'=>$this->id, 'ac'=>$http->request('ac'),
|
||||
'gDossier'=>dossier::id()));
|
||||
echo $op->form_get('do.php?'.$url);
|
||||
echo '</div>';
|
||||
|
|
|
|||
120
include/class/operation_predef_mtable.class.php
Normal file
120
include/class/operation_predef_mtable.class.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu
|
||||
/*! \file
|
||||
* \brief Class to manage predefined operation thanks the class Manage Table
|
||||
*/
|
||||
/*!
|
||||
* \brief Display a table and allow to change the predefined operation, insert or delete. Used the
|
||||
* class Manage_Table_SQL and the SQL Object for the tables op_predef and op_predef_detail.
|
||||
*/
|
||||
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";
|
||||
|
||||
class Operation_Predef_MTable extends Manage_Table_SQL
|
||||
{
|
||||
private $pre_operation;
|
||||
function __construct(Op_predef_SQL $p_table)
|
||||
{
|
||||
parent::__construct($p_table);
|
||||
|
||||
$this->set_property_visible("od_id",false);
|
||||
$this->set_property_visible("od_direct",false);
|
||||
$this->set_property_visible("od_item",false);
|
||||
$this->set_col_label("jrn_def_id",_("Journal"));
|
||||
$this->set_col_label("od_name",_("Nom"));
|
||||
$this->set_col_label("od_jrn_type",_("Type de journal"));
|
||||
$this->set_col_label("od_description",_("Description"));
|
||||
|
||||
$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_order(array("jrn_def_id","od_name","od_description","od_jrn_type"));
|
||||
$this->set_col_type("jrn_def_id","select",$aLedger);
|
||||
|
||||
$this->set_callback("ajax_misc.php");
|
||||
$this->set_property_updatable("jrn_def_id",false);
|
||||
$this->set_property_updatable("od_jrn_type",false);
|
||||
$this->pre_operation=null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form
|
||||
* @throws Exception
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from the request
|
||||
* - table is the sql table
|
||||
* - ctl_id is the dialog box id
|
||||
* - p_id = predef_op.od_id
|
||||
*
|
||||
* @code
|
||||
* json = {"table":"public.op_predef",
|
||||
"ctl_id":"dtr",
|
||||
"ac":"COMPTA/ADV/PREDOP",
|
||||
"op":"save_predf",
|
||||
"gDossier":["28", "28"],
|
||||
"p_id":"15",
|
||||
"action":"save",
|
||||
"ctl":"tbl5f6a1d09035f2",
|
||||
"nb_item":"10",
|
||||
"e_client":"",
|
||||
"p_jrn":"2",
|
||||
"e_march0":"MARCHA",
|
||||
"e_march0_price":"102.0000",
|
||||
"e_quant0":"1.0000",
|
||||
"htva_march0":"0",
|
||||
"e_march0_tva_id":"4",
|
||||
"bt_e_march0_tva_id":"+TVA+",
|
||||
"e_march0_tva_amount":"0.0000",
|
||||
"tva_march0":"0","tvac_march0":"0",
|
||||
"jrn_type":"VEN",
|
||||
"5f6a1d0b23242_ledger":"O","
|
||||
5f6a1d0b23242":"1",
|
||||
"update":"OK",
|
||||
"5f6a1d5b70997_ledger":"O",
|
||||
"5f6a1d5b70997":"1"}
|
||||
* @endcode
|
||||
*/
|
||||
function from_request()
|
||||
{
|
||||
$http=new HttpInput();
|
||||
$obj=$this->get_table();
|
||||
$this->pre_operation=new Pre_operation($obj->cn);
|
||||
$this->pre_operation->get_post();
|
||||
$this->pre_operation->set_od_id($http->post("p_id","number"));
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$this->pre_operation->save();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -29,97 +29,86 @@ require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
|||
*/
|
||||
class Pre_op_ach extends Pre_operation_detail
|
||||
{
|
||||
var $op;
|
||||
function __construct($cn,$p_id=0)
|
||||
function __construct($cn)
|
||||
{
|
||||
parent::__construct($cn,$p_id);
|
||||
|
||||
$this->operation->od_direct='f';
|
||||
parent::__construct($cn);
|
||||
}
|
||||
|
||||
function get_post()
|
||||
{
|
||||
parent::get_post();
|
||||
$http=new HttpInput();
|
||||
$this->operation->od_direct='f';
|
||||
$http = new \HttpInput();
|
||||
$nb = $http->post("nb_item", "number");
|
||||
$this->e_client=$http->post('e_client');
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
{
|
||||
$march="e_march".$i;
|
||||
$this->$march=$http->post('e_march'.$i);
|
||||
$this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","string",0);
|
||||
$this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","string",0);
|
||||
$this->{"e_march".$i."_tva_id"}=$http->post('e_march'.$i."_tva_id","string",0);
|
||||
$this->{"e_march".$i."_tva_amount"}=$http->post('e_march'.$i."_tva_amount","string",0);
|
||||
$this->{"e_march".$i."_label"}=$http->post('e_march'.$i."_label","string",NULL);
|
||||
$this->{"e_quant".$i}=$http->post('e_quant'.$i);
|
||||
|
||||
for ($i = 0; $i < $nb; $i++) {
|
||||
$march = "e_march" . $i;
|
||||
$http->set_empty("");
|
||||
$this->$march = $http->post('e_march' . $i);
|
||||
$this->{"e_march" . $i . "_tva_id"} = $http->post('e_march' . $i . "_tva_id", "string", 0);
|
||||
$this->{"e_march" . $i . "_tva_id"} = $http->post('e_march' . $i . "_tva_id", "string", "0");
|
||||
$this->{"e_march" . $i . "_label"} = $http->post('e_march' . $i . "_label", "string", "");
|
||||
$http->set_empty(0);
|
||||
$this->{"e_march" . $i . "_price"} = $http->post('e_march' . $i . "_price","number");
|
||||
$this->{"e_march" . $i . "_tva_amount"} = $http->post('e_march' . $i . "_tva_amount", "string", "0");
|
||||
$this->{"e_quant" . $i} = $http->post('e_quant' . $i, "number");
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief save the detail and op in the database
|
||||
*
|
||||
*/
|
||||
function save()
|
||||
function save($p_od_id,$p_nb_item)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->db->start();
|
||||
if ($this->operation->save() == false )
|
||||
return;
|
||||
// save the client
|
||||
$sql=sprintf('insert into op_predef_detail (od_id,opd_poste,opd_debit)'.
|
||||
' values '.
|
||||
"(%d,'%s','%s')",
|
||||
$this->operation->od_id,
|
||||
$this->e_client,
|
||||
"f");
|
||||
' values '.
|
||||
"(%d,'%s','%s')",
|
||||
$p_od_id,
|
||||
$this->e_client,
|
||||
"f");
|
||||
$this->db->exec_sql($sql);
|
||||
// save the selling
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
|
||||
for ($i=0;$i<$p_nb_item;$i++)
|
||||
{
|
||||
if ( strlen(trim($this->{"e_march".$i}))=="") continue;
|
||||
$sql= 'insert into op_predef_detail (opd_poste,'
|
||||
. 'opd_amount,'
|
||||
. 'opd_tva_id,'
|
||||
. 'opd_quantity,'
|
||||
. 'opd_debit,'
|
||||
. 'od_id ,'
|
||||
. 'opd_tva_amount,'
|
||||
. 'opd_comment'.
|
||||
')'.
|
||||
' values ($1,$2,$3,$4,$5,$6,$7,$8)';
|
||||
. 'opd_amount,'
|
||||
. 'opd_tva_id,'
|
||||
. 'opd_quantity,'
|
||||
. 'opd_debit,'
|
||||
. 'od_id ,'
|
||||
. 'opd_tva_amount,'
|
||||
. 'opd_comment'.
|
||||
')'.
|
||||
' values ($1,$2,$3,$4,$5,$6,$7,$8)';
|
||||
$this->db->exec_sql($sql,
|
||||
array($this->{"e_march".$i},
|
||||
$this->{"e_march".$i."_price"},
|
||||
$this->{"e_march".$i."_tva_id"},
|
||||
$this->{"e_quant".$i},
|
||||
't',
|
||||
$this->operation->od_id,
|
||||
$this->{"e_march".$i."_tva_amount"},
|
||||
$this->{"e_march".$i."_label"},
|
||||
));
|
||||
array($this->{"e_march".$i},
|
||||
$this->{"e_march".$i."_price"},
|
||||
$this->{"e_march".$i."_tva_id"},
|
||||
$this->{"e_quant".$i},
|
||||
't',
|
||||
$p_od_id,
|
||||
$this->{"e_march".$i."_tva_amount"},
|
||||
$this->{"e_march".$i."_label"},
|
||||
));
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
echo ($e->getMessage());
|
||||
$this->db->rollback();
|
||||
record_log("PREOPACH01".$e->getMessage().$e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
$this->db->commit();
|
||||
}
|
||||
/*!\brief compute an array accordingly with the FormVenView function
|
||||
* @return an array for filling the form
|
||||
*/
|
||||
function compute_array()
|
||||
function compute_array($p_od_id)
|
||||
{
|
||||
$count=0;
|
||||
$a_op=$this->operation->load();
|
||||
$array=$this->operation->compute_array($a_op);
|
||||
$p_array=$this->load();
|
||||
if ( empty ($p_array)) return array();
|
||||
$array=array();
|
||||
$p_array=$this->load($p_od_id);
|
||||
if (empty($p_array)) return array();
|
||||
foreach ($p_array as $row)
|
||||
{
|
||||
if ( $row['opd_debit']=='f')
|
||||
|
|
@ -128,19 +117,20 @@ class Pre_op_ach extends Pre_operation_detail
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( trim($row['opd_poste']) !="" )
|
||||
if ( trim($row['opd_poste']) != "")
|
||||
{
|
||||
$array+=array("e_march".$count=>$row['opd_poste'],
|
||||
"e_march".$count."_price"=>$row['opd_amount'],
|
||||
"e_march".$count."_tva_id"=>$row['opd_tva_id'],
|
||||
"e_march".$count."_tva_amount"=>$row['opd_tva_amount'],
|
||||
"e_quant".$count=>$row['opd_quantity']
|
||||
);
|
||||
"e_march".$count."_price"=>$row['opd_amount'],
|
||||
"e_march".$count."_tva_id"=>$row['opd_tva_id'],
|
||||
"e_quant".$count=>$row['opd_quantity'],
|
||||
"e_march".$count."_label"=>$row['opd_comment'],
|
||||
"e_march".$count."_tva_amount"=>$row['opd_tva_amount'],
|
||||
);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$array['nb_item']=$count;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
/**
|
||||
|
|
@ -148,263 +138,260 @@ class Pre_op_ach extends Pre_operation_detail
|
|||
* load the data from the database and return an array
|
||||
* \return an array
|
||||
*/
|
||||
function load()
|
||||
function load($p_od_id)
|
||||
{
|
||||
$sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,".
|
||||
" opd_quantity,opd_tva_amount from op_predef_detail where od_id=".$this->operation->od_id.
|
||||
" order by opd_id";
|
||||
$res=$this->db->exec_sql($sql);
|
||||
" 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]);
|
||||
$array=Database::fetch_all($res);
|
||||
return $array;
|
||||
}
|
||||
function set_od_id($p_id)
|
||||
{
|
||||
$this->operation->od_id=$p_id;
|
||||
}
|
||||
|
||||
function display($p_array)
|
||||
{
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger_purchase.class.php';
|
||||
global $g_parameter,$g_user;
|
||||
extract($p_array, EXTR_SKIP);
|
||||
$ledger=new Acc_Ledger_Purchase($this->db,$this->jrn_def_id);
|
||||
if ( $p_array != null ) extract($p_array, EXTR_SKIP);
|
||||
$ledger=new Acc_Ledger_Purchase($this->db,$p_array['p_jrn']);
|
||||
|
||||
$flag_tva=$g_parameter->MY_TVA_USE;
|
||||
/* Add button */
|
||||
$f_add_button=new IButton('add_card');
|
||||
$f_add_button->label=_('Créer une nouvelle fiche');
|
||||
$f_add_button->tabindex=-1;
|
||||
$f_add_button->set_attribute('ipopup','ipop_newcard');
|
||||
$f_add_button->set_attribute('jrn',$this->jrn_def_id);
|
||||
$f_add_button->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);";
|
||||
$flag_tva=$g_parameter->MY_TVA_USE;
|
||||
/* Add button */
|
||||
$f_add_button=new IButton('add_card');
|
||||
$f_add_button->tabindex=-1;
|
||||
$f_add_button->label=_('Créer une nouvelle fiche');
|
||||
$f_add_button->set_attribute('ipopup','ipop_newcard');
|
||||
$f_add_button->set_attribute('jrn',$p_array['p_jrn']);
|
||||
$f_add_button->javascript="this.jrn=\$('p_jrn').value; select_card_type(this);";
|
||||
|
||||
$f_add_button2=new IButton('add_card2');
|
||||
$f_add_button2->tabindex=-1;
|
||||
$f_add_button2->label=_('Créer une nouvelle fiche');
|
||||
$f_add_button2->set_attribute('ipopup','ipop_newcard');
|
||||
$f_add_button2->set_attribute('filter',$ledger->get_all_fiche_def ());
|
||||
// $f_add_button2->set_attribute('jrn',$ledger->id);
|
||||
$f_add_button2->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);";
|
||||
$str_add_button="";
|
||||
$str_add_button2="";
|
||||
if ($g_user->check_action(FICADD)==1)
|
||||
{
|
||||
$str_add_button=$f_add_button->input();
|
||||
$str_add_button2=$f_add_button2->input();
|
||||
}
|
||||
$f_add_button2=new IButton('add_card2');
|
||||
$f_add_button2->tabindex=-1;
|
||||
$f_add_button2->label=_('Créer une nouvelle fiche');
|
||||
$f_add_button2->set_attribute('ipopup','ipop_newcard');
|
||||
$f_add_button2->set_attribute('filter',$ledger->get_all_fiche_def ());
|
||||
// $f_add_button2->set_attribute('jrn',$ledger->id);
|
||||
$f_add_button2->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);";
|
||||
|
||||
$r="";
|
||||
$r.=dossier::hidden();
|
||||
$f_legend=_("En-tête facture fournisseur");
|
||||
$f_legend_detail=_("Détail articles acheté");
|
||||
$str_add_button="";
|
||||
$str_add_button2="";
|
||||
if ($g_user->check_action(FICADD)==1)
|
||||
{
|
||||
$str_add_button=$f_add_button->input();
|
||||
$str_add_button2=$f_add_button2->input();
|
||||
}
|
||||
|
||||
// Ledger (p_jrn)
|
||||
//--
|
||||
/* if we suggest the next pj, then we need a javascript */
|
||||
$add_js="";
|
||||
|
||||
// Display the customer
|
||||
//--
|
||||
$fiche='cred';
|
||||
|
||||
// Save old value and set a new one
|
||||
//--
|
||||
$e_client=( isset ($e_client) )?$e_client:"";
|
||||
$e_client_label=" ";//str_pad("",100,".");
|
||||
$r='';
|
||||
$r.=dossier::hidden();
|
||||
$f_legend=_('En-tête facture fournisseur');
|
||||
|
||||
|
||||
// retrieve e_client_label
|
||||
//--
|
||||
/* if we suggest the next pj, then we need a javascript */
|
||||
|
||||
if ( strlen(trim($e_client)) != 0)
|
||||
{
|
||||
$fClient=new Fiche($ledger->db);
|
||||
$fClient->get_by_qcode($e_client);
|
||||
$e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '.
|
||||
' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '.
|
||||
$fClient->strAttribut(ATTR_DEF_CP).' '.
|
||||
$fClient->strAttribut(ATTR_DEF_CITY).' ';
|
||||
// Display the customer
|
||||
//--
|
||||
$fiche='deb';
|
||||
|
||||
// Save old value and set a new one
|
||||
//--
|
||||
$e_client=( isset ($p_array["e_client"]) )?$p_array["e_client"]:"";
|
||||
$e_client_label=" ";//str_pad("",100,".");
|
||||
|
||||
|
||||
}
|
||||
// retrieve e_client_label
|
||||
//--
|
||||
|
||||
$W1=new ICard();
|
||||
$W1->label=_("Fournisseur ").Icon_Action::infobulle(0) ;
|
||||
$W1->name="e_client";
|
||||
$W1->tabindex=3;
|
||||
$W1->value=$e_client;
|
||||
$W1->table=0;
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup','ipopcard');
|
||||
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('label','e_client_label');
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('typecard','cred');
|
||||
|
||||
// Add the callback function to filter the card on the jrn
|
||||
$W1->set_callback('filter_card');
|
||||
$W1->set_function('fill_data');
|
||||
$W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
|
||||
$W1->name);
|
||||
$f_client_qcode=$W1->input();
|
||||
$client_label=new ISpan();
|
||||
$client_label->table=0;
|
||||
$f_client=$client_label->input("e_client_label",$e_client_label);
|
||||
$f_client_bt=$W1->search();
|
||||
if ( strlen(trim($e_client)) != 0)
|
||||
{
|
||||
$fClient=new Fiche($ledger->db);
|
||||
$fClient->get_by_qcode($e_client);
|
||||
$e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '.
|
||||
' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '.
|
||||
$fClient->strAttribut(ATTR_DEF_CP).' '.
|
||||
$fClient->strAttribut(ATTR_DEF_CITY).' ';
|
||||
|
||||
|
||||
// Record the current number of article
|
||||
$min=$ledger->get_min_row();
|
||||
$p_article= ( isset ($nb_item))?$nb_item:$min;
|
||||
$max=($p_article < $min)?$min:$p_article;
|
||||
}
|
||||
|
||||
$e_comment=(isset($e_comment))?$e_comment:"";
|
||||
$Hid=new IHidden();
|
||||
$r.=$Hid->input("nb_item",$p_article);
|
||||
// For each article
|
||||
//--
|
||||
for ($i=0;$i< $max ;$i++)
|
||||
{
|
||||
// Code id, price & vat code
|
||||
//--
|
||||
$march=(isset(${"e_march$i"}))?${"e_march$i"}:"" ;
|
||||
$march_price=(isset(${"e_march".$i."_price"}))?${"e_march".$i."_price"}:""
|
||||
;
|
||||
/* use vat */
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
{
|
||||
$march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
|
||||
$march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:"";
|
||||
}
|
||||
$W1=new ICard();
|
||||
$W1->label="Client ".Icon_Action::infobulle(0) ;
|
||||
$W1->name="e_client";
|
||||
$W1->tabindex=3;
|
||||
$W1->value=$e_client;
|
||||
$W1->table=0;
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup','ipopcard');
|
||||
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('label','e_client_label');
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('typecard','cred');
|
||||
|
||||
// Add the callback function to filter the card on the jrn
|
||||
$W1->set_callback('filter_card');
|
||||
$W1->set_function('fill_data');
|
||||
$W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
|
||||
$W1->name);
|
||||
$f_client_qcode=$W1->input();
|
||||
$client_label=new ISpan();
|
||||
$client_label->table=0;
|
||||
$f_client=$client_label->input("e_client_label",$e_client_label);
|
||||
$f_client_bt=$W1->search();
|
||||
|
||||
|
||||
// Record the current number of article
|
||||
$min=$ledger->get_min_row();
|
||||
$p_article= ( isset ($p_array["nb_item"]))?$p_array["nb_item"]:$min;
|
||||
$max=($p_article < $min)?$min:$p_article;
|
||||
|
||||
$e_comment=(isset($p_array["e_comment"]))?$p_array["e_comment"]:"";
|
||||
$Hid=new IHidden();
|
||||
$r.=$Hid->input("nb_item",$p_article);
|
||||
|
||||
$f_legend_detail=_("Détail articles achetés");
|
||||
|
||||
// For each article
|
||||
//--
|
||||
for ($i=0;$i< $max;$i++)
|
||||
{
|
||||
// Code id, price & vat code
|
||||
//--
|
||||
$march=(isset($p_array["e_march$i"]))?$p_array["e_march$i"]:""
|
||||
;
|
||||
$march_price=(isset($p_array["e_march".$i."_price"]))?$p_array["e_march".$i."_price"]:""
|
||||
;
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
$march_tva_id=(isset($p_array["e_march$i"."_tva_id"]))?$p_array["e_march$i"."_tva_id"]:"";
|
||||
$march_tva_amount=(isset($p_array["e_march$i"."_tva_amount"]))?$p_array["e_march$i"."_tva_amount"]:"";
|
||||
}
|
||||
$march_label=(isset($p_array["e_march".$i."_label"]))?$p_array["e_march".$i."_label"]:"";
|
||||
|
||||
// retrieve the tva label and name
|
||||
//--
|
||||
if ( strlen(trim($march))!=0 && strlen(trim($march_label))==0)
|
||||
{
|
||||
$fMarch=new Fiche($ledger->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
if ( ! (isset($p_array["e_march$i"."_tva_id"])))
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
}
|
||||
}
|
||||
// Show input
|
||||
//--
|
||||
$W1=new ICard();
|
||||
$W1->label="";
|
||||
$W1->name="e_march".$i;
|
||||
$W1->value=$march;
|
||||
$W1->table=1;
|
||||
$W1->set_attribute('typecard','deb');
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup','ipopcard');
|
||||
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('label','e_march'.$i.'_label');
|
||||
// name of the field with the price
|
||||
$W1->set_attribute('price','e_march'.$i.'_price');
|
||||
// name of the field with the TVA_ID
|
||||
$W1->set_attribute('tvaid','e_march'.$i.'_tva_id');
|
||||
// Add the callback function to filter the card on the jrn
|
||||
$W1->set_callback('filter_card');
|
||||
$W1->set_function('fill_data');
|
||||
$W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
|
||||
$W1->name);
|
||||
|
||||
$W1->readonly=false;
|
||||
|
||||
$array[$i]['quick_code']=$W1->input();
|
||||
$array[$i]['bt']=$W1->search();
|
||||
// For computing we need some hidden field for holding the value
|
||||
$array[$i]['hidden']='';
|
||||
if ( $flag_tva=='Y') $array[$i]['hidden'].=HtmlInput::hidden('tva_march'.$i,0);
|
||||
|
||||
$htva=new INum('htva_march'.$i);
|
||||
$htva->readOnly=1;
|
||||
$htva->value=0;
|
||||
$array[$i]['htva']=$htva->input();
|
||||
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
$tvac=new INum('tvac_march'.$i);
|
||||
else
|
||||
$tvac=new IHidden('tvac_march'.$i);
|
||||
|
||||
$tvac->readOnly=1;
|
||||
$tvac->value=0;
|
||||
$array[$i]['tvac']=$tvac->input();
|
||||
|
||||
if ( $g_parameter->MY_UPDLAB == 'Y')
|
||||
{
|
||||
$Span=new IText("e_march".$i."_label");
|
||||
|
||||
$Span->css_size="100%";
|
||||
} else
|
||||
{
|
||||
$Span=new ISpan("e_march".$i."_label");
|
||||
}
|
||||
$Span->value=$march_label;
|
||||
$Span->setReadOnly(false);
|
||||
// card's name, price
|
||||
//--
|
||||
$array[$i]['denom']=$Span->input("e_march".$i."_label",$march_label);
|
||||
// price
|
||||
$Price=new INum();
|
||||
$Price->setReadOnly(false);
|
||||
$Price->prec=4;
|
||||
$Price->size=9;
|
||||
$Price->javascript="onBlur='format_number(this);clean_tva($i);compute_ledger($i)'";
|
||||
$array[$i]['pu']=$Price->input("e_march".$i."_price",$march_price);
|
||||
$array[$i]['tva']='';
|
||||
$array[$i]['amount_tva']='';
|
||||
// if tva is not needed then no tva field
|
||||
if ( $flag_tva == 'Y' )
|
||||
{
|
||||
// vat label
|
||||
//--
|
||||
$Tva=new ITva_Popup($ledger->db);
|
||||
$Tva->in_table=true;
|
||||
$Tva->set_attribute('compute',$i);
|
||||
|
||||
$Tva->js='onblur="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"';
|
||||
$Tva->value=$march_tva_id;
|
||||
$array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
|
||||
// vat amount
|
||||
//--
|
||||
$wTva_amount=new INum();
|
||||
$wTva_amount->readOnly=false;
|
||||
$wTva_amount->size=6;
|
||||
$wTva_amount->javascript="onBlur='format_number(this);compute_ledger($i)'";
|
||||
$array[$i]['amount_tva']=$wTva_amount->input("e_march".$i."_tva_amount",$march_tva_amount);
|
||||
}
|
||||
// quantity
|
||||
//--
|
||||
$quant=(isset($p_array["e_quant$i"]))?$p_array["e_quant$i"]:"1"
|
||||
;
|
||||
$Quantity=new INum();
|
||||
$Quantity->setReadOnly(false);
|
||||
$Quantity->size=8;
|
||||
$Quantity->javascript="onChange='format_number(this);clean_tva($i);compute_ledger($i)'";
|
||||
$array[$i]['quantity']=$Quantity->input("e_quant".$i,$quant);
|
||||
|
||||
}// foreach article
|
||||
$f_type=_('Client');
|
||||
|
||||
|
||||
ob_start();
|
||||
require_once NOALYSS_TEMPLATE.'/predf_ledger_detail.php';
|
||||
$r.=ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
|
||||
$march_label=(isset(${"e_march".$i."_label"}))?${"e_march".$i."_label"}:"";
|
||||
// retrieve the tva label and name
|
||||
//--
|
||||
if ( strlen(trim($march))!=0 && strlen(trim($march_label))==0 )
|
||||
{
|
||||
$fMarch=new Fiche($ledger->db);
|
||||
$fMarch->get_by_qcode($march);
|
||||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
/* vat use */
|
||||
if ( ! isset($march_tva_id) && $g_parameter->MY_TVA_USE=='Y' )
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
}
|
||||
// Show input
|
||||
//--
|
||||
$W1=new ICard();
|
||||
$W1->label="";
|
||||
$W1->name="e_march".$i;
|
||||
$W1->value=$march;
|
||||
$W1->table=1;
|
||||
$W1->set_dblclick("fill_ipopcard(this);");
|
||||
$W1->set_attribute('ipopup','ipopcard');
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$r.=HtmlInput::hidden('jrn_type','ACH');
|
||||
$r.= Html_Input_Noalyss::ledger_add_item("O");
|
||||
|
||||
$W1->set_attribute('typecard','deb');
|
||||
|
||||
// name of the field to update with the name of the card
|
||||
$W1->set_attribute('label','e_march'.$i.'_label');
|
||||
// name of the field with the price
|
||||
$W1->set_attribute('purchase','e_march'.$i.'_price'); /* autocomplete */
|
||||
$W1->set_attribute('price','e_march'.$i.'_price'); /* via search */
|
||||
|
||||
// name of the field with the TVA_ID
|
||||
$W1->set_attribute('tvaid','e_march'.$i.'_tva_id');
|
||||
// Add the callback function to filter the card on the jrn
|
||||
$W1->set_callback('filter_card');
|
||||
$W1->set_function('fill_data');
|
||||
$W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
|
||||
$W1->name);
|
||||
$W1->readonly=false;
|
||||
$array[$i]['quick_code']=$W1->input();
|
||||
$array[$i]['bt']=$W1->search();
|
||||
|
||||
$array[$i]['hidden']='';
|
||||
// For computing we need some hidden field for holding the value
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
{
|
||||
$array[$i]['hidden'].=HtmlInput::hidden('tva_march'.$i,0);
|
||||
}
|
||||
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
$tvac=new INum('tvac_march'.$i);
|
||||
else
|
||||
$tvac=new IHidden('tvac_march'.$i);
|
||||
|
||||
$tvac->readOnly=1;
|
||||
$tvac->value=0;
|
||||
$array[$i]['tvac']=$tvac->input();
|
||||
|
||||
$htva=new INum('htva_march'.$i);
|
||||
$htva->readOnly=1;
|
||||
|
||||
$htva->value=0;
|
||||
$array[$i]['htva']=$htva->input();
|
||||
|
||||
if ( $g_parameter->MY_UPDLAB == 'Y')
|
||||
{
|
||||
$Span=new IText("e_march".$i."_label");
|
||||
$Span->css_size="100%";
|
||||
} else
|
||||
{
|
||||
$Span=new ISpan("e_march".$i."_label");
|
||||
}
|
||||
$Span->value=$march_label;
|
||||
$Span->setReadOnly(false);
|
||||
// card's name, price
|
||||
//--
|
||||
$array[$i]['denom']=$Span->input("e_march".$i."_label",$march_label);
|
||||
// price
|
||||
$Price=new INum();
|
||||
$Price->prec=4;
|
||||
$Price->setReadOnly(false);
|
||||
$Price->size=9;
|
||||
$Price->javascript="onBlur='format_number(this);clean_tva($i);compute_ledger($i)'";
|
||||
$array[$i]['pu']=$Price->input("e_march".$i."_price",$march_price);
|
||||
if ( $g_parameter->MY_TVA_USE=='Y')
|
||||
{
|
||||
|
||||
// vat label
|
||||
//--
|
||||
$Tva=new ITva_Popup($ledger->db);
|
||||
$Tva->js="onblur=\"format_number(this);onChange=clean_tva($i);compute_ledger($i)\"";
|
||||
$Tva->in_table=true;
|
||||
$Tva->set_attribute('compute',$i);
|
||||
$Tva->value=$march_tva_id;
|
||||
$array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
|
||||
|
||||
// Tva_amount
|
||||
|
||||
// price
|
||||
$Tva_amount=new INum();
|
||||
$Tva_amount->setReadOnly(false);
|
||||
$Tva_amount->size=9;
|
||||
$Tva_amount->javascript="onBlur='format_number(this);compute_ledger($i)'";
|
||||
$array[$i]['amount_tva']=$Tva_amount->input("e_march".$i."_tva_amount",$march_tva_amount);
|
||||
}
|
||||
// quantity
|
||||
//--
|
||||
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"
|
||||
;
|
||||
$Quantity=new INum();
|
||||
$Quantity->setReadOnly(false);
|
||||
$Quantity->size=9;
|
||||
$Quantity->javascript="onChange=format_number(this);clean_tva($i);compute_ledger($i)";
|
||||
$array[$i]['quantity']=$Quantity->input("e_quant".$i,$quant);
|
||||
|
||||
}
|
||||
$f_type=_('Fournisseur');
|
||||
|
||||
ob_start();
|
||||
require_once NOALYSS_TEMPLATE.'/predf_ledger_detail.php';
|
||||
$r.=ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$r.= HtmlInput::hidden('jrn_type','ACH');
|
||||
$r.= Html_Input_Noalyss::ledger_add_item("O");
|
||||
return $r;
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,18 +29,16 @@ require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
|||
*/
|
||||
class Pre_Op_Advanced extends Pre_operation_detail
|
||||
{
|
||||
var $op;
|
||||
function __construct($cn)
|
||||
{
|
||||
parent::__construct($cn);
|
||||
$this->operation->od_direct='t';
|
||||
}
|
||||
function get_post()
|
||||
{
|
||||
parent::get_post();
|
||||
$http=new HttpInput();
|
||||
$http = new \HttpInput();
|
||||
$nb = $http->post("nb_item", "number");
|
||||
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
for ($i=0;$i<$nb;$i++)
|
||||
{
|
||||
$poste=$http->post("poste".$i,"string", null);
|
||||
$qcode=$http->post("qc_".$i,"string", null);
|
||||
|
|
@ -54,10 +52,14 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
}
|
||||
|
||||
if ( $qcode != null && trim ($qcode) != "") {
|
||||
$this->{'isqc'.$i}=(trim($_POST['qc_'.$i]) != "")?'t':'f';
|
||||
$this->{'isqc'.$i}=(trim($http->post('qc_'.$i)) != "")?'t':'f';
|
||||
$this->{'poste'.$i}=trim ($qcode);
|
||||
}
|
||||
$this->{"amount".$i}=$_POST['amount'.$i];
|
||||
}
|
||||
$http->set_empty(0);
|
||||
$this->{"amount".$i}=$http->post('amount'.$i);
|
||||
$http->set_empty("");
|
||||
$this->{"ld".$i}=$http->post("ld".$i);
|
||||
|
||||
$this->{"ck".$i}=(isset($_POST['ck'.$i]))?'t':'f';
|
||||
|
||||
}
|
||||
|
|
@ -66,60 +68,53 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
* \brief save the detail and op in the database
|
||||
*
|
||||
*/
|
||||
function save()
|
||||
function save($p_od_id,$p_nb_item)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($this->operation->save() == false )
|
||||
return;
|
||||
$this->db->start();
|
||||
// save the selling
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
for ($i=0;$i<$p_nb_item;$i++)
|
||||
{
|
||||
if ( ! isset ($this->{"poste".$i}))
|
||||
continue;
|
||||
|
||||
$sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
|
||||
'opd_debit,od_id,opd_qc)'.
|
||||
' values '.
|
||||
"('%s',%.2f,'%s',%d,'%s')",
|
||||
$this->{"poste".$i},
|
||||
$this->{"amount".$i},
|
||||
$this->{"ck".$i},
|
||||
$this->operation->od_id,
|
||||
$this->{'isqc'.$i}
|
||||
'opd_debit,od_id,opd_qc,opd_comment)'.
|
||||
' values($1,$2,$3,$4,$5,$6) '
|
||||
);
|
||||
|
||||
$this->db->exec_sql($sql);
|
||||
$this->db->exec_sql($sql,[$this->{"poste".$i},
|
||||
$this->{"amount".$i},
|
||||
$this->{"ck".$i},
|
||||
$p_od_id,
|
||||
$this->{'isqc'.$i},
|
||||
$this->{"ld".$i}]);
|
||||
|
||||
}
|
||||
$this->db->commit();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
echo ($e->getMessage());
|
||||
$this->db->rollback();
|
||||
record_log($e->getMessage().$e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
/*!\brief compute an array accordingly with the FormVenView function
|
||||
*/
|
||||
function compute_array()
|
||||
function compute_array($p_od_id)
|
||||
{
|
||||
$count=0;
|
||||
$a_op=$this->operation->load();
|
||||
$array=$this->operation->compute_array($a_op);
|
||||
$array['desc']=$array['e_comm'];
|
||||
$p_array=$this->load();
|
||||
$array=array();
|
||||
$p_array=$this->load($p_od_id);
|
||||
if (empty($p_array)) return array();
|
||||
foreach ($p_array as $row)
|
||||
{
|
||||
$tmp_array=array("qc_".$count=>'',
|
||||
"poste".$count=>'',
|
||||
"amount".$count=>$row['opd_amount'],
|
||||
'ck'.$count=>$row['opd_debit']
|
||||
'ck'.$count=>$row['opd_debit'],
|
||||
"ld".$count=>$row['opd_comment']
|
||||
);
|
||||
|
||||
if ( $row['opd_qc'] == 't' )
|
||||
|
|
@ -141,28 +136,22 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
/*!\brief load the data from the database and return an array
|
||||
* \return an array
|
||||
*/
|
||||
function load()
|
||||
function load($p_od_id)
|
||||
{
|
||||
$sql="select opd_id,opd_poste,opd_amount,opd_debit,".
|
||||
" opd_qc from op_predef_detail where od_id=".$this->operation->od_id.
|
||||
$sql="select opd_id,opd_poste,opd_amount,opd_debit,opd_comment,".
|
||||
" opd_qc from op_predef_detail where od_id=$1 ".
|
||||
" order by opd_id";
|
||||
$res=$this->db->exec_sql($sql);
|
||||
$res=$this->db->exec_sql($sql,[$p_od_id]);
|
||||
$array=Database::fetch_all($res);
|
||||
return $array;
|
||||
}
|
||||
function set_od_id($p_id)
|
||||
{
|
||||
$this->operation->od_id=$p_id;
|
||||
}
|
||||
function display($p_array)
|
||||
function display($p_array)
|
||||
{
|
||||
global $g_parameter, $g_user;
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
|
||||
$legder=new Acc_Ledger($this->db,$this->jrn_def_id);
|
||||
$legder=new Acc_Ledger($this->db,$p_array['p_jrn']);
|
||||
$legder->nb=$legder->get_min_row();
|
||||
|
||||
if ($p_array != null)
|
||||
extract($p_array, EXTR_SKIP);
|
||||
$add_js = "";
|
||||
|
||||
$ret = "";
|
||||
|
|
@ -177,10 +166,10 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
$f_add_button->input();
|
||||
}
|
||||
|
||||
$nb_row = (isset($nb_item) ) ? $nb_item : $legder->nb;
|
||||
$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', $this->jrn_def_id);
|
||||
$ret.=HtmlInput::hidden('p_jrn', $p_array['p_jrn']);
|
||||
$ret.=dossier::hidden();
|
||||
|
||||
$ret.=dossier::hidden();
|
||||
|
|
@ -220,7 +209,7 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
$quick_code->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $quick_code->name);
|
||||
|
||||
$quick_code->jrn = $legder->id;
|
||||
$quick_code->value = (isset(${'qc_' . $i})) ? ${'qc_' . $i} : "";
|
||||
$quick_code->value = (isset($p_array['qc_' . $i])) ? $p_array['qc_' . $i]: "";
|
||||
|
||||
$label = '';
|
||||
if ($quick_code->value != '')
|
||||
|
|
@ -240,7 +229,7 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
$poste->set_attribute('account', 'poste' . $i);
|
||||
$poste->set_attribute('dossier', Dossier::id());
|
||||
|
||||
$poste->value = (isset(${'poste' . $i})) ? ${"poste" . $i} : ''
|
||||
$poste->value = (isset($p_array['poste' . $i])) ?$p_array['poste' . $i]: ''
|
||||
;
|
||||
$poste->dbl_click_history();
|
||||
|
||||
|
|
@ -256,20 +245,20 @@ class Pre_Op_Advanced extends Pre_operation_detail
|
|||
$line_desc = new IText();
|
||||
$line_desc->name = 'ld' . $i;
|
||||
$line_desc->size = 30;
|
||||
$line_desc->value = (isset(${"ld" . $i})) ? ${"ld" . $i} :
|
||||
$line_desc->value = (isset($p_array["ld" . $i])) ? $p_array["ld" . $i] :
|
||||
$label;
|
||||
|
||||
// Amount
|
||||
$amount = new INum();
|
||||
$amount->size = 10;
|
||||
$amount->name = 'amount' . $i;
|
||||
$amount->value = (isset(${'amount' . $i})) ? ${"amount" . $i} : ''
|
||||
$amount->value = (isset($p_array['amount' . $i])) ?$p_array['amount' . $i] : ''
|
||||
;
|
||||
$amount->javascript = ' onChange="format_number(this);checkTotalDirect()"';
|
||||
// D/C
|
||||
$deb = new ICheckBox();
|
||||
$deb->name = 'ck' . $i;
|
||||
$deb->selected = (isset(${'ck' . $i})) ? true : false;
|
||||
$deb->selected = (isset($p_array['ck' . $i])) ? true : false;
|
||||
$deb->javascript = ' onChange="checkTotalDirect()"';
|
||||
|
||||
$ret.='<tr>';
|
||||
|
|
|
|||
|
|
@ -30,22 +30,23 @@ require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
|||
class Pre_op_ods extends Pre_operation_detail
|
||||
{
|
||||
var $op;
|
||||
function __construct($cn,$p_id=0)
|
||||
function __construct($cn)
|
||||
{
|
||||
parent::__construct($cn,$p_id);
|
||||
$this->operation->od_direct='f';
|
||||
parent::__construct($cn);
|
||||
}
|
||||
|
||||
/***
|
||||
* @brief retrieve data from $_POST
|
||||
*/
|
||||
function get_post()
|
||||
{
|
||||
parent::get_post();
|
||||
$this->operation->od_direct='f';
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
$http=new \HttpInput();
|
||||
$nb=$http->post("nb_item","number");
|
||||
for ($i=0;$i< $nb ;$i++)
|
||||
{
|
||||
|
||||
$this->{"e_account".$i}=$_POST['e_account'.$i];
|
||||
$this->{"e_account".$i."_amount"}=$_POST['e_account'.$i."_amount"];
|
||||
$this->{"e_account".$i."_type"}=$_POST['e_account'.$i."_type"];
|
||||
$this->{"e_account".$i}=$http->post("e_account'.$i");
|
||||
$this->{"e_account".$i."_amount"}=$http->post("e_account".$i."_amount","number",0);
|
||||
$this->{"e_account".$i."_type"}=$http->post('e_account'.$i."_type");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -53,45 +54,38 @@ class Pre_op_ods extends Pre_operation_detail
|
|||
* \brief save the detail and op in the database
|
||||
*
|
||||
*/
|
||||
function save()
|
||||
function save($p_od_id,$p_nbitem)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->db->start();
|
||||
if ($this->operation->save() == false )
|
||||
return;
|
||||
|
||||
// save the selling
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
for ($i=0;$i< $p_nbitem ;$i++)
|
||||
{
|
||||
$sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
|
||||
$sql='insert into op_predef_detail (opd_poste,opd_amount,'.
|
||||
'opd_debit,od_id)'.
|
||||
' values '.
|
||||
"('%s',%.2f,'%s',%d)",
|
||||
$this->{"e_account".$i},
|
||||
$this->{"e_account".$i."_amount"},
|
||||
($this->{"e_account".$i."_type"}=='d')?'t':'f',
|
||||
$this->operation->od_id
|
||||
);
|
||||
$this->db->exec_sql($sql);
|
||||
' values ($1,$2,$3,$4)';
|
||||
|
||||
$this->db->exec_sql($sql,array($this->{"e_account".$i},
|
||||
$this->{"e_account".$i."_amount"},
|
||||
($this->{"e_account".$i."_type"}=='d')?'t':'f',
|
||||
$p_od_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
record_log($e);
|
||||
echo ($e->getMessage());
|
||||
$this->db->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
/*!\brief compute an array accordingly with the FormVenView function
|
||||
*/
|
||||
function compute_array()
|
||||
function compute_array($p_od_id)
|
||||
{
|
||||
$count=0;
|
||||
$a_op=$this->operation->load();
|
||||
$array=$this->operation->compute_array($a_op);
|
||||
$p_array=$this->load();
|
||||
$p_array=$this->load($p_od_id);
|
||||
foreach ($p_array as $row)
|
||||
{
|
||||
$c=($row['opd_debit']=='t')?'d':'c';
|
||||
|
|
@ -107,17 +101,13 @@ class Pre_op_ods extends Pre_operation_detail
|
|||
/*!\brief load the data from the database and return an array
|
||||
* \return an array
|
||||
*/
|
||||
function load()
|
||||
function load($p_od_id)
|
||||
{
|
||||
$sql="select opd_id,opd_poste,opd_amount,opd_debit".
|
||||
" from op_predef_detail where od_id=".$this->operation->od_id.
|
||||
" from op_predef_detail where od_id= $1 ".
|
||||
" order by opd_debit, opd_id,opd_amount";
|
||||
$res=$this->db->exec_sql($sql);
|
||||
$res=$this->db->exec_sql($sql,array($p_od_id));
|
||||
$array=Database::fetch_all($res);
|
||||
return $array;
|
||||
}
|
||||
function set_od_id($p_id)
|
||||
{
|
||||
$this->operation->od_id=$p_id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,53 +29,49 @@ require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
|||
*/
|
||||
class Pre_op_ven extends Pre_operation_detail
|
||||
{
|
||||
var $op;
|
||||
//< Pre_operation
|
||||
function __construct($cn,$p_id=0)
|
||||
function __construct($cn)
|
||||
{
|
||||
parent::__construct($cn,$p_id);
|
||||
$this->operation->od_direct='f'; //< Pre_operation
|
||||
parent::__construct($cn);
|
||||
}
|
||||
|
||||
function get_post()
|
||||
{
|
||||
parent::get_post();
|
||||
$this->operation->od_direct='f';
|
||||
$this->e_client=$_POST['e_client'];
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
$http=new \HttpInput();
|
||||
$nb=$http->post("nb_item","number");
|
||||
$this->e_client=$http->post("e_client");
|
||||
for ($i=0;$i< $nb;$i++)
|
||||
{
|
||||
$march="e_march".$i;
|
||||
$this->$march=$_POST['e_march'.$i];
|
||||
$this->{"e_march".$i."_price"}=$_POST['e_march'.$i."_price"];
|
||||
$this->{"e_march".$i."_tva_id"}=(isset($_POST['e_march'.$i."_tva_id"]))?$_POST['e_march'.$i."_tva_id"]:0;
|
||||
$this->{"e_march".$i."_tva_amount"}=(isset($_POST['e_march'.$i."_tva_amount"]))?$_POST['e_march'.$i."_tva_amount"]:0;
|
||||
$this->{"e_march".$i."_tva_id"}=(isset($_POST['e_march'.$i."_tva_id"]))?$_POST['e_march'.$i."_tva_id"]:0;
|
||||
$this->{"e_march".$i."_label"}=(isset($_POST['e_march'.$i."_label"]))?$_POST['e_march'.$i."_label"]:null;
|
||||
$this->{"e_quant".$i}=$_POST['e_quant'.$i];
|
||||
$http->set_empty("");
|
||||
$this->$march=$http->post('e_march'.$i);
|
||||
$this->{"e_march".$i."_tva_id"}=$http->post('e_march'.$i."_tva_id","string",0);
|
||||
$this->{"e_march".$i."_tva_id"}=$http->post('e_march'.$i."_tva_id","string","0");
|
||||
$this->{"e_march".$i."_label"}=$http->post('e_march'.$i."_label","string","");
|
||||
|
||||
$http->set_empty(0);
|
||||
$this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","number");
|
||||
$this->{"e_march".$i."_tva_amount"}=$http->post('e_march'.$i."_tva_amount","number","0");
|
||||
$this->{"e_quant".$i}=$http->post('e_quant'.$i,"number");
|
||||
}
|
||||
}
|
||||
/*!
|
||||
* \brief save the detail and op in the database
|
||||
*
|
||||
*/
|
||||
function save()
|
||||
function save($p_od_id,$p_nb_item)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->db->start();
|
||||
if ($this->operation->save() == false )
|
||||
return;
|
||||
// save the client
|
||||
$sql=sprintf('insert into op_predef_detail (od_id,opd_poste,opd_debit)'.
|
||||
' values '.
|
||||
"(%d,'%s','%s')",
|
||||
$this->operation->od_id,
|
||||
$this->e_client,
|
||||
"t");
|
||||
' values '.
|
||||
"(%d,'%s','%s')",
|
||||
$p_od_id,
|
||||
$this->e_client,
|
||||
"t");
|
||||
$this->db->exec_sql($sql);
|
||||
// save the selling
|
||||
for ($i=0;$i<$this->operation->nb_item;$i++)
|
||||
for ($i=0;$i<$p_nb_item;$i++)
|
||||
{
|
||||
if ( strlen(trim($this->{"e_march".$i}))=="") continue;
|
||||
$sql= 'insert into op_predef_detail (opd_poste,'
|
||||
|
|
@ -94,7 +90,7 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
$this->{"e_march".$i."_tva_id"},
|
||||
$this->{"e_quant".$i},
|
||||
'f',
|
||||
$this->operation->od_id,
|
||||
$p_od_id,
|
||||
$this->{"e_march".$i."_tva_amount"},
|
||||
$this->{"e_march".$i."_label"},
|
||||
));
|
||||
|
|
@ -102,21 +98,17 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
record_log($e);
|
||||
echo ($e->getMessage());
|
||||
$this->db->rollback();
|
||||
record_log("PREOPVEN01".$e->getMessage().$e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
$this->db->commit();
|
||||
|
||||
}
|
||||
/*!\brief compute an array accordingly with the FormVenView function
|
||||
*/
|
||||
function compute_array()
|
||||
function compute_array($p_od_id)
|
||||
{
|
||||
$count=0;
|
||||
$a_op=$this->operation->load();
|
||||
$array=$this->operation->compute_array($a_op);
|
||||
$p_array=$this->load();
|
||||
$array=array();
|
||||
$p_array=$this->load($p_od_id);
|
||||
if (empty($p_array)) return array();
|
||||
foreach ($p_array as $row)
|
||||
{
|
||||
|
|
@ -139,37 +131,33 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
}
|
||||
}
|
||||
}
|
||||
// Find the ledger
|
||||
$ledger=new Acc_Ledger($this->db,$this->operation->jrn_def_id);
|
||||
// Find the max line of the ledger
|
||||
$max_row=$ledger->get_min_row();
|
||||
|
||||
// compute nb_item
|
||||
$array['nb_item']=($max_row > $count)?$max_row:$count;
|
||||
|
||||
return $array;
|
||||
}
|
||||
/*!\brief load the data from the database and return an array
|
||||
* \return an array
|
||||
*/
|
||||
function load()
|
||||
function load($p_od_id)
|
||||
{
|
||||
$sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,".
|
||||
" opd_quantity , opd_comment,opd_tva_amount from op_predef_detail where od_id=".$this->operation->od_id.
|
||||
" 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);
|
||||
$res=$this->db->exec_sql($sql,[$p_od_id]);
|
||||
$array=Database::fetch_all($res);
|
||||
return $array;
|
||||
}
|
||||
function set_od_id($p_id)
|
||||
{
|
||||
$this->operation->od_id=$p_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $p_array
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function display($p_array)
|
||||
{
|
||||
global $g_parameter,$g_user;
|
||||
if ( $p_array != null ) extract($p_array, EXTR_SKIP);
|
||||
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger_sold.class.php';
|
||||
$ledger=new Acc_Ledger_Sold($this->db,$this->jrn_def_id);
|
||||
$ledger=new Acc_Ledger_Sold($this->db,$p_array['p_jrn']);
|
||||
|
||||
$flag_tva=$g_parameter->MY_TVA_USE;
|
||||
/* Add button */
|
||||
|
|
@ -177,7 +165,7 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
$f_add_button->tabindex=-1;
|
||||
$f_add_button->label=_('Créer une nouvelle fiche');
|
||||
$f_add_button->set_attribute('ipopup','ipop_newcard');
|
||||
$f_add_button->set_attribute('jrn',$ledger->id);
|
||||
$f_add_button->set_attribute('jrn',$p_array['p_jrn']);
|
||||
$f_add_button->javascript="this.jrn=\$('p_jrn').value; select_card_type(this);";
|
||||
|
||||
$f_add_button2=new IButton('add_card2');
|
||||
|
|
@ -209,7 +197,7 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
|
||||
// Save old value and set a new one
|
||||
//--
|
||||
$e_client=( isset ($e_client) )?$e_client:"";
|
||||
$e_client=( isset ($p_array["e_client"]) )?$p_array["e_client"]:"";
|
||||
$e_client_label=" ";//str_pad("",100,".");
|
||||
|
||||
|
||||
|
|
@ -256,10 +244,10 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
|
||||
// Record the current number of article
|
||||
$min=$ledger->get_min_row();
|
||||
$p_article= ( isset ($nb_item))?$nb_item:$min;
|
||||
$p_article= ( isset ($p_array["nb_item"]))?$p_array["nb_item"]:$min;
|
||||
$max=($p_article < $min)?$min:$p_article;
|
||||
|
||||
$e_comment=(isset($e_comment))?$e_comment:"";
|
||||
$e_comment=(isset($p_array["e_comment"]))?$p_array["e_comment"]:"";
|
||||
$Hid=new IHidden();
|
||||
$r.=$Hid->input("nb_item",$p_article);
|
||||
|
||||
|
|
@ -271,16 +259,16 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
{
|
||||
// Code id, price & vat code
|
||||
//--
|
||||
$march=(isset(${"e_march$i"}))?${"e_march$i"}:""
|
||||
$march=(isset($p_array["e_march$i"]))?$p_array["e_march$i"]:""
|
||||
;
|
||||
$march_price=(isset(${"e_march".$i."_price"}))?${"e_march".$i."_price"}:""
|
||||
$march_price=(isset($p_array["e_march".$i."_price"]))?$p_array["e_march".$i."_price"]:""
|
||||
;
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
$march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
|
||||
$march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:"";
|
||||
$march_tva_id=(isset($p_array["e_march$i"."_tva_id"]))?$p_array["e_march$i"."_tva_id"]:"";
|
||||
$march_tva_amount=(isset($p_array["e_march$i"."_tva_amount"]))?$p_array["e_march$i"."_tva_amount"]:"";
|
||||
}
|
||||
$march_label=(isset(${"e_march".$i."_label"}))?${"e_march".$i."_label"}:"";
|
||||
$march_label=(isset($p_array["e_march".$i."_label"]))?$p_array["e_march".$i."_label"]:"";
|
||||
|
||||
// retrieve the tva label and name
|
||||
//--
|
||||
|
|
@ -291,7 +279,7 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
$march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
|
||||
if ( $flag_tva=='Y')
|
||||
{
|
||||
if ( ! (isset(${"e_march$i"."_tva_id"})))
|
||||
if ( ! (isset($p_array["e_march$i"."_tva_id"])))
|
||||
$march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
|
||||
}
|
||||
}
|
||||
|
|
@ -385,7 +373,7 @@ class Pre_op_ven extends Pre_operation_detail
|
|||
}
|
||||
// quantity
|
||||
//--
|
||||
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"
|
||||
$quant=(isset($p_array["e_quant$i"]))?$p_array["e_quant$i"]:"1"
|
||||
;
|
||||
$Quantity=new INum();
|
||||
$Quantity->setReadOnly(false);
|
||||
|
|
|
|||
|
|
@ -34,19 +34,29 @@ require_once NOALYSS_INCLUDE.'/class/pre_op_ven.class.php';
|
|||
require_once NOALYSS_INCLUDE.'/class/pre_op_advanced.class.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 */
|
||||
var $detail; /*!< Pre_operation_detail */
|
||||
|
||||
private $db; /*!< $db database connection */
|
||||
private $nb_item; /*!< $nb_item nb of item */
|
||||
private $p_jrn; /*!< $p_jrn jrn_def_id */
|
||||
private $jrn_type; /*!< $jrn_type */
|
||||
private $name; /*!< $name name of the predef. operation */
|
||||
private $detail; /*!< Pre_operation_detail object */
|
||||
private $od_direct ; /*!< Compatibility for ACH in direct mode, only for ODS */
|
||||
private $od_id; /*!< id of the Predefined Operation */
|
||||
private $isloaded;
|
||||
private $description; /*!< description of the predefined operation */
|
||||
function __construct($cn,$p_id=0)
|
||||
{
|
||||
$this->db=$cn;
|
||||
$this->od_direct='false';
|
||||
$this->od_direct='f';
|
||||
$this->od_id=$p_id;
|
||||
$this->p_jrn=0;
|
||||
$this->jrn_type='x';
|
||||
$this->name='';
|
||||
$this->isloaded=false;
|
||||
$this->description="";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Propose to save the operation into a predefined operation
|
||||
* @return HTML string
|
||||
|
|
@ -56,7 +66,7 @@ class Pre_operation
|
|||
$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();
|
||||
$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>';
|
||||
|
|
@ -67,6 +77,21 @@ class Pre_operation
|
|||
$r.='</p>';
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_description()
|
||||
{
|
||||
return $this->description;
|
||||
}/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function set_description($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/*!\brief fill the object with the $_POST variable */
|
||||
function get_post()
|
||||
|
|
@ -77,29 +102,55 @@ class Pre_operation
|
|||
$this->jrn_type=$http->post('jrn_type');
|
||||
$this->name=$http->post('opd_name');
|
||||
|
||||
$this->name=(trim($this->name)=='')?$http->post('e_comm'):$this->name;
|
||||
$this->description= $http->post('od_description');
|
||||
if ( $this->name=="")
|
||||
{
|
||||
$n=$this->db->get_next_seq('op_def_op_seq');
|
||||
$this->name=$this->jrn_type.$n;
|
||||
// common value
|
||||
|
||||
}
|
||||
|
||||
// get also info for the details
|
||||
// common value
|
||||
$this->detail=Pre_operation_detail::build_detail($this->jrn_type,$this->db);
|
||||
$this->detail->get_post();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a template operation and children
|
||||
*/
|
||||
function delete ()
|
||||
{
|
||||
$sql="delete from op_predef where od_id=$1";
|
||||
$this->db->exec_sql($sql,array($this->od_id));
|
||||
}
|
||||
function save()
|
||||
{
|
||||
if ($this->od_id < 1) {
|
||||
$this->save_insert();
|
||||
} else {
|
||||
$this->save_update();
|
||||
}
|
||||
|
||||
}
|
||||
function save_update()
|
||||
{
|
||||
$sql = "update op_predef set jrn_def_id = $1 , od_name = $2 ,
|
||||
od_item =$3, od_description = $4 where od_id=$5";
|
||||
$this->db->exec_sql($sql,array($this->p_jrn,$this->name,$this->nb_item,$this->description,$this->od_id));
|
||||
// delete detail&
|
||||
$this->db->exec_sql("delete from op_predef_detail where od_id = $1",array($this->od_id));
|
||||
$this->detail->save($this->od_id,$this->nb_item);
|
||||
}
|
||||
/*!\brief save the predef check first is the name is unique
|
||||
* \return true op.success otherwise false
|
||||
*/
|
||||
function save()
|
||||
function save_insert()
|
||||
{
|
||||
|
||||
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)
|
||||
"and jrn_def_id=".$this->p_jrn." and od_id <> ".$this->od_id)
|
||||
!= 0 )
|
||||
{
|
||||
$this->name="copy_".$this->name."_".microtime(true);
|
||||
|
|
@ -109,24 +160,44 @@ class Pre_operation
|
|||
echo '<span class="notice">'.("Vous avez atteint le max. d'opération prédéfinie, désolé").'</span>';
|
||||
return false;
|
||||
}
|
||||
$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,
|
||||
$this->name,
|
||||
$this->nb_item,
|
||||
$this->jrn_type,
|
||||
$this->od_direct,
|
||||
$this->description,
|
||||
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,
|
||||
$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->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) {
|
||||
record_log("PROP139.Failed save predefined operation ");
|
||||
$this->db->rollback();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/*!\brief load the data from the database and return an array
|
||||
* \return an array
|
||||
* \return an double array containing all the data from database
|
||||
*/
|
||||
function load()
|
||||
{
|
||||
$this->isloaded=true;
|
||||
//------------------------------------------
|
||||
// if new , then od_id == 0 and we need to use blank()
|
||||
//------------------------------------------
|
||||
if ($this->od_id == -1 ) {
|
||||
$array=$this->blank($this->p_jrn);
|
||||
return $array;
|
||||
}
|
||||
$sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description".
|
||||
" from op_predef where od_id=$1 ".
|
||||
" order by od_name";
|
||||
|
|
@ -135,27 +206,41 @@ class Pre_operation
|
|||
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) {
|
||||
case 'ACH':
|
||||
$this->detail=new Pre_op_ach($this->db);
|
||||
break;
|
||||
case 'VEN':
|
||||
$this->detail=new Pre_Op_ven($this->db);
|
||||
break;
|
||||
case 'ODS':
|
||||
$this->detail=new Pre_op_advanced($this->db);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf(_('Echec PreOperatoin chargement %s'),$this->od_jrn_type));
|
||||
}
|
||||
$this->detail->set_od_id($this->od_id);
|
||||
$this->detail->jrn_def_id=$this->jrn_def_id;
|
||||
|
||||
$this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
|
||||
$array+=$this->detail->load($this->od_id);
|
||||
return $array;
|
||||
}
|
||||
/**
|
||||
* create a blank object to insert it later
|
||||
* @param $p_ledger_id
|
||||
* @throws Exception
|
||||
*/
|
||||
function blank($p_ledger_id) {
|
||||
$array["od_id"]=-1;
|
||||
$array['jrn_def_id']=$p_ledger_id;
|
||||
$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_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;
|
||||
}
|
||||
|
||||
function compute_array()
|
||||
{
|
||||
$p_array=$this->load();
|
||||
if ($this->od_id > 0) {
|
||||
$p_array = $this->load();
|
||||
} else {
|
||||
$p_array=$this->blank($this->p_jrn);
|
||||
}
|
||||
$array=array(
|
||||
"e_comm"=>$p_array[0]["od_name"],
|
||||
"nb_item"=>(($p_array[0]["od_item"]<10)?10:$p_array[0]["od_item"]) ,
|
||||
|
|
@ -163,6 +248,8 @@ class Pre_operation
|
|||
"jrn_type"=>$p_array[0]["od_jrn_type"],
|
||||
"od_description"=>$p_array['0']['od_description']
|
||||
);
|
||||
$this->detail = Pre_operation_detail::build_detail($this->od_jrn_type, $this->db);
|
||||
$array += $this->detail->compute_array($this->od_id);
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
|
@ -187,9 +274,9 @@ class Pre_operation
|
|||
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");
|
||||
" where jrn_def_id= $1 ".
|
||||
" and od_direct = $2 ".
|
||||
" order by od_name",array($this->p_jrn,$this->od_direct));
|
||||
return $a;
|
||||
}
|
||||
/*!\brief get the list of the predef. operation of a ledger
|
||||
|
|
@ -198,21 +285,14 @@ class Pre_operation
|
|||
function get_list_ledger()
|
||||
{
|
||||
$sql="select od_id,od_name,od_description from op_predef ".
|
||||
" where jrn_def_id=".$this->p_jrn.
|
||||
" and od_direct ='".$this->od_direct."'".
|
||||
" where jrn_def_id= $1 ".
|
||||
" and od_direct = $2 ".
|
||||
" order by od_name";
|
||||
$res=$this->db->exec_sql($sql);
|
||||
$res=$this->db->exec_sql($sql,array($this->p_jrn,$this->od_direct));
|
||||
$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 display the detail of predefined operation, normally everything
|
||||
|
|
@ -220,67 +300,43 @@ class Pre_operation
|
|||
*/
|
||||
function display()
|
||||
{
|
||||
$array=$this->detail->compute_array();
|
||||
$array=$this->compute_array();
|
||||
require NOALYSS_TEMPLATE."/pre_operation_display.php";
|
||||
echo $this->detail->display($array);
|
||||
}
|
||||
}
|
||||
|
||||
/*!\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,$p_id=0)
|
||||
{
|
||||
$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');
|
||||
$this->jrn_def_id=-1;
|
||||
}
|
||||
|
||||
|
||||
/*!\brief show a form to use pre_op
|
||||
*/
|
||||
*/
|
||||
function form_get ($p_url)
|
||||
{
|
||||
$r=HtmlInput::button_action(_("Modèle d'opérations"), ' $(\'modele_op_div\').style.display=\'block\';if ( $(\'lk_modele_op_tab\')) { $(\'lk_modele_op_tab\').focus();}');
|
||||
$r=HtmlInput::button_action(_("Modèle d'opérations"),
|
||||
' $(\'modele_op_div\').style.display=\'block\';if ( $(\'lk_modele_op_tab\')) { $(\'lk_modele_op_tab\').focus();}');
|
||||
$r.='<div id="modele_op_div" class="noprint">';
|
||||
$r.=HtmlInput::title_box(_("Modèle d'opérations"), 'modele_op_div', 'hide',"","n");
|
||||
$hid=new IHidden();
|
||||
$r.=$hid->input("action","use_opd");
|
||||
$r.=$hid->input("jrn_type",$this->get("ledger_type"));
|
||||
$r.= $this->show_button($p_url);
|
||||
$r.=$hid->input("jrn_type",$this->jrn_type);
|
||||
$r.= $this->display_list_operation($p_url);
|
||||
$r.=' <p style="text-align: center">'.
|
||||
HtmlInput::button_hide('modele_op_div').
|
||||
'</p>';
|
||||
HtmlInput::button_hide('modele_op_div').
|
||||
'</p>';
|
||||
$r.='</div>';
|
||||
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($p_url)
|
||||
function display_list_operation($p_url)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
$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();
|
||||
|
||||
" where jrn_def_id=$1".
|
||||
" and od_direct =$2".
|
||||
" order by od_name",
|
||||
array($this->p_jrn,$this->od_direct ));
|
||||
|
||||
if ( $this->p_jrn=='') $value=array();
|
||||
|
||||
$r="";
|
||||
if (count($value)==0) {
|
||||
$r.=_("Vous n'avez encore sauvé aucun modèle");
|
||||
|
|
@ -292,7 +348,7 @@ class Pre_operation_detail
|
|||
$r.='<tr class="'.(($i%2==0)?"even":"odd").'">';
|
||||
$r.='<td style="font-weight:bold;vertical-align:top;text-decoration:underline">';
|
||||
$r.=sprintf('<a href="%s&pre_def=%s" onclick="waiting_box()">%s</a> ',
|
||||
$p_url,$value[$i]['od_id'],$value[$i]['od_name']);
|
||||
$p_url,$value[$i]['od_id'],$value[$i]['od_name']);
|
||||
$r.='</td>';
|
||||
$r.='<td>'.h($value[$i]['od_description']).'</td>';
|
||||
$r.='</tr>';
|
||||
|
|
@ -302,38 +358,181 @@ class Pre_operation_detail
|
|||
}
|
||||
public function get_operation()
|
||||
{
|
||||
if ( $this->jrn_def_id=='') return array();
|
||||
if ( $this->jrn_def_id=='') return array();
|
||||
$value=$this->db->make_array("select od_id,od_name from op_predef ".
|
||||
" where jrn_def_id=".sql_string($this->jrn_def_id).
|
||||
" and od_direct ='".sql_string($this->od_direct)."'".
|
||||
" order by od_name",1);
|
||||
" where jrn_def_id=".sql_string($this->jrn_def_id).
|
||||
" and od_direct ='".sql_string($this->od_direct)."'".
|
||||
" order by od_name",1);
|
||||
return $value;
|
||||
}
|
||||
function set($p_param,$value)
|
||||
{
|
||||
if ( ! isset ($this->valid[$p_param] ) )
|
||||
{
|
||||
$msg=_(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
$attr=$this->valid[$p_param];
|
||||
$this->$attr=$value;
|
||||
}
|
||||
function get($p_param)
|
||||
{
|
||||
|
||||
if ( ! isset ($this->valid[$p_param] ) )
|
||||
{
|
||||
$msg=_(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
$attr=$this->valid[$p_param];
|
||||
return $this->$attr;
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_db()
|
||||
{
|
||||
return $this->db;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function get_post()
|
||||
/**
|
||||
* @param mixed $db
|
||||
*/
|
||||
public function set_db($db)
|
||||
{
|
||||
$this->operation->get_post();
|
||||
$this->db = $db;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_nb_item()
|
||||
{
|
||||
return $this->nb_item;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $nb_item
|
||||
*/
|
||||
public function set_nb_item($nb_item)
|
||||
{
|
||||
$this->nb_item = $nb_item;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_jrn_type()
|
||||
{
|
||||
return $this->jrn_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $jrn_type
|
||||
*/
|
||||
public function set_jrn_type($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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_name()
|
||||
{
|
||||
return $this->name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function set_name($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_detail()
|
||||
{
|
||||
return $this->detail;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $detail
|
||||
*/
|
||||
public function set_detail(Pre_operation_detail $detail)
|
||||
{
|
||||
$this->detail = $detail;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_od_direct()
|
||||
{
|
||||
return $this->od_direct;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $od_direct
|
||||
*/
|
||||
public function set_od_direct($od_direct)
|
||||
{
|
||||
if ( ! in_array($od_direct,['f','t'])) throw new Exception('prop02.invalid od_direct');
|
||||
$this->od_direct = $od_direct;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function get_od_id()
|
||||
{
|
||||
return $this->od_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|mixed $od_id
|
||||
*/
|
||||
public function set_od_id($od_id)
|
||||
{
|
||||
$this->od_id = $od_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/*!\brief set the ledger
|
||||
* \param $p_jrn is the ledger (jrn_id)
|
||||
*/
|
||||
function set_p_jrn($p_jrn)
|
||||
{
|
||||
$this->p_jrn=$p_jrn;
|
||||
$this->jrn_type=$this->db->get_value("select jrn_def_type from jrn_def where jrn_def_id=$1",[$p_jrn]);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/*!\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
|
||||
{
|
||||
function __construct($p_cn)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
|
||||
}
|
||||
|
||||
static function build_detail($p_jrn_type,Database $database)
|
||||
{
|
||||
switch ($p_jrn_type) {
|
||||
case 'ACH':
|
||||
$detail=new Pre_op_ach($database);
|
||||
break;
|
||||
case 'VEN':
|
||||
$detail=new Pre_Op_ven($database);
|
||||
break;
|
||||
case 'ODS':
|
||||
$detail=new Pre_op_advanced($database);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(sprintf(_('Echec PreOperatoin chargement %s'),$p_jrn_type));
|
||||
}
|
||||
return $detail;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger_purchase.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_op_ach.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/ipopup.class.php';
|
||||
$gDossier = dossier::id();
|
||||
global $g_parameter;
|
||||
|
|
@ -153,7 +153,7 @@ if (isset($_POST['record']))
|
|||
/* Save the predefined operation */
|
||||
if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
|
||||
{
|
||||
$opd = new Pre_op_ach($cn);
|
||||
$opd = new Pre_operation($cn);
|
||||
$opd->get_post();
|
||||
$opd->save();
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ try
|
|||
// used a predefined operation
|
||||
$predef=$http->request("pre_def","string", "0");
|
||||
$p_jrn_predef=$http->request("p_jrn_predef","string", "0");
|
||||
$op=new Pre_op_ach($cn);
|
||||
$op=new Pre_operation($cn);
|
||||
$op->set_od_id($predef);
|
||||
$p_post=$op->compute_array();
|
||||
$Ledger->id=$p_jrn_predef;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger_sold.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_op_ven.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/document.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger_info.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/ipopup.class.php';
|
||||
|
|
@ -171,7 +171,7 @@ show_tabs(a_tab,'facturation_div_id');
|
|||
/* Save the predefined operation */
|
||||
if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
|
||||
{
|
||||
$opd=new Pre_op_ven($cn);
|
||||
$opd=new Pre_operation($cn);
|
||||
$opd->get_post();
|
||||
$opd->save();
|
||||
}
|
||||
|
|
@ -253,22 +253,14 @@ if (!isset($_REQUEST ['p_jrn']))
|
|||
$Ledger->id=$def_ledger['jrn_def_id'];
|
||||
}
|
||||
else
|
||||
$Ledger->id=$_REQUEST ['p_jrn'];
|
||||
$Ledger->id=$http->request('p_jrn');
|
||||
|
||||
if (isset($_REQUEST['p_jrn_predef']))
|
||||
{
|
||||
$Ledger->id=$_REQUEST['p_jrn_predef'];
|
||||
$Ledger->id=$http->request('p_jrn_predef');
|
||||
}
|
||||
|
||||
/* echo '<div id="predef_form">';
|
||||
echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
|
||||
$op=new Pre_op_ven($cn);
|
||||
$op->set('ledger',$Ledger->id);
|
||||
$op->set('ledger_type',"VEN");
|
||||
$op->set('direct','f');
|
||||
$url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
|
||||
echo $op->form_get('do.php?'.$url);
|
||||
echo '</div>';
|
||||
*/
|
||||
|
||||
echo '<div class="content">';
|
||||
if ( $p_msg !="" ) echo '<span class="warning">'.$p_msg.'</span>';
|
||||
try
|
||||
|
|
@ -284,10 +276,10 @@ try
|
|||
{
|
||||
// used a predefined operation
|
||||
//
|
||||
$op=new Pre_op_ven($cn);
|
||||
$op->set_od_id($_REQUEST['pre_def']);
|
||||
$op=new Pre_operation($cn);
|
||||
$op->set_od_id($http->request('pre_def'));
|
||||
$p_post=$op->compute_array();
|
||||
$Ledger->id=$_REQUEST ['p_jrn_predef'];
|
||||
$Ledger->id=$http->request('p_jrn_predef');
|
||||
|
||||
echo $Ledger->input($p_post);
|
||||
echo '<div class="content">';
|
||||
|
|
|
|||
71
include/database/op_predef_sql.class.php
Normal file
71
include/database/op_predef_sql.class.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Autogenerated file
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/database.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* class_op_predef_sql.php
|
||||
*
|
||||
*@file
|
||||
*@brief abstract of the table public.op_predef */
|
||||
class Op_predef_SQL extends Noalyss_SQL
|
||||
{
|
||||
|
||||
function __construct(Database $p_cn,$p_id=-1)
|
||||
{
|
||||
$this->table = "public.op_predef";
|
||||
$this->primary_key = "od_id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name=array(
|
||||
"od_id"=>"od_id"
|
||||
,"jrn_def_id"=>"jrn_def_id"
|
||||
,"od_name"=>"od_name"
|
||||
,"od_item"=>"od_item"
|
||||
,"od_jrn_type"=>"od_jrn_type"
|
||||
,"od_direct"=>"od_direct"
|
||||
,"od_description"=>"od_description"
|
||||
);
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type = array(
|
||||
"od_id"=>"numeric"
|
||||
,"jrn_def_id"=>"numeric"
|
||||
,"od_name"=>"text"
|
||||
,"od_item"=>"numeric"
|
||||
,"od_jrn_type"=>"text"
|
||||
,"od_direct"=>"boolean"
|
||||
,"od_description"=>"text"
|
||||
);
|
||||
|
||||
|
||||
$this->default = array(
|
||||
"od_id" => "auto"
|
||||
);
|
||||
|
||||
$this->date_format = "DD.MM.YYYY";
|
||||
parent::__construct($p_cn,$p_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -25,7 +25,8 @@
|
|||
* \brief to write into the ledgers ODS a new operation
|
||||
*/
|
||||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_op_ods.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
||||
|
||||
require_once NOALYSS_INCLUDE.'/lib/iconcerned.class.php';
|
||||
|
||||
global $g_user,$g_parameter;
|
||||
|
|
@ -59,7 +60,7 @@ if ( isset ($_GET['action']) && ! isset($_POST['correct']) && ! isset($correct)
|
|||
if ( $_GET['action']=='use_opd')
|
||||
{
|
||||
// get data from predef. operation
|
||||
$op=new Pre_op_advanced($cn);
|
||||
$op=new Pre_operation($cn);
|
||||
$p_post=null;
|
||||
if ( isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != '')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,105 +22,17 @@
|
|||
/*!\file
|
||||
* \brief included file for managing the predefined operation
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/class/operation_predef_mtable.class.php';
|
||||
|
||||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/database.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/pre_operation.class.php';
|
||||
global $http;
|
||||
/*
|
||||
* Value from $_GET or $_REQUEST
|
||||
*/
|
||||
$request_jrn=$http->request("jrn","string", -1);
|
||||
$request_ac=$http->request("ac","string", "");
|
||||
$request_sa=$http->request("sa","string", "");
|
||||
$get_jrn=$http->get('jrn',"string",-1);
|
||||
|
||||
echo '<div class="content">';
|
||||
echo '<form method="GET">';
|
||||
$sel=new ISelect();
|
||||
$sel->name="jrn";
|
||||
$sel->value=$cn->make_array("select jrn_def_id,jrn_def_name from ".
|
||||
" jrn_def where jrn_def_type in ('VEN','ACH','ODS') order by jrn_def_name");
|
||||
// Show a list of ledger
|
||||
$sel->selected=$request_jrn;
|
||||
echo 'Choisissez un journal '.$sel->input();
|
||||
$prd_op=new Op_predef_SQL($cn);
|
||||
|
||||
echo dossier::hidden();
|
||||
$hid=new IHidden();
|
||||
echo $hid->input("sa","jrn");
|
||||
echo $hid->input("ac",$request_ac);
|
||||
echo '<hr>';
|
||||
echo HtmlInput::submit('Accepter','Accepter');
|
||||
echo '</form>';
|
||||
|
||||
// if $_REQUEST[sa] == del delete the predefined operation
|
||||
if ( $request_sa == 'del')
|
||||
{
|
||||
$op=new Pre_operation($cn);
|
||||
$http=new HttpInput();
|
||||
$op->od_id=$http->request('od_id',"string",-1);
|
||||
if (isNumber($op->od_id)==1 && $op->od_id != -1 )
|
||||
{
|
||||
$op->delete();
|
||||
}
|
||||
$request_sa='jrn';
|
||||
}
|
||||
|
||||
// if $_REQUEST[sa] == jrn show the predefined operation for this
|
||||
// ledger
|
||||
if ( $request_sa== 'jrn' )
|
||||
{
|
||||
$op=new Pre_operation($cn);
|
||||
$op->set_jrn($get_jrn);
|
||||
$is_ods = $cn->get_value("select count(*)
|
||||
from jrn_def where
|
||||
jrn_def_id=$1
|
||||
and jrn_def_type='ODS'", array($get_jrn));
|
||||
$op->od_direct = ($is_ods > 0) ? 't' : 'f';
|
||||
$array = $op->get_list_ledger();
|
||||
if (empty($array) == true)
|
||||
{
|
||||
echo _("Aucun enregistrement");
|
||||
return;
|
||||
}
|
||||
echo HtmlInput::filter_table('preod_table', '0', 0);
|
||||
echo '<table id="preod_table">';
|
||||
$count=0;
|
||||
foreach ($array as $row )
|
||||
{
|
||||
|
||||
if ( $count %2 == 0 )
|
||||
echo '<tr class="odd">';
|
||||
else
|
||||
echo '<tr class="even">';
|
||||
$count++;
|
||||
|
||||
echo '<td>'.h($row['od_name']).'</td>';
|
||||
echo '<td>'.h($row['od_description']).'</td>';
|
||||
echo '<td>';
|
||||
echo '<form method="POST" id="preod_frm'.$row['od_id'].'" class="print" style="margin:0px;padding:0px;">';
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::hidden("sa","del");
|
||||
echo HtmlInput::hidden("ac",$request_ac);
|
||||
echo HtmlInput::hidden("del","");
|
||||
echo HtmlInput::hidden("od_id",$row['od_id']);
|
||||
echo HtmlInput::hidden("jrn",$get_jrn);
|
||||
|
||||
$b='<input type="submit" class="smallbutton" value="'._("Effacer").'"'.
|
||||
' onClick="return confirm_box(\'preod_frm'.$row['od_id'].'\',\''._("Voulez-vous vraiment effacer cette operation ?").'\');" >';
|
||||
echo $b;
|
||||
echo '</form>';
|
||||
|
||||
echo '</td>';
|
||||
$b=HtmlInput::button('mod'.$row['od_id'],"Modifier","onclick=\"mod_predf_op('".dossier::id()."','".$row['od_id']."');\"");
|
||||
echo td($b);
|
||||
echo '</tr>';
|
||||
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
echo '</div>';
|
||||
?>
|
||||
$operation_predef_mtable=new Operation_Predef_MTable($prd_op);
|
||||
$operation_predef_mtable->set_json(json_encode(array( "ac"=>$http->request("ac"),
|
||||
"op"=>"save_predf",
|
||||
"gDossier"=>Dossier::id()
|
||||
)));
|
||||
$operation_predef_mtable->create_js_script();
|
||||
$operation_predef_mtable->display_table();
|
||||
36
include/template/pre_operation_display.php
Normal file
36
include/template/pre_operation_display.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu
|
||||
|
||||
/**
|
||||
* @file
|
||||
* display pre_operation value
|
||||
*/
|
||||
|
||||
$name=new IText("opd_name",$array["e_comm"]);
|
||||
$description=new IText("od_description",$array["od_description"]);
|
||||
$description->style=' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
|
||||
|
||||
?>
|
||||
<?php echo _("Nom du modèle"),$name->input();?>
|
||||
<p>
|
||||
<?php echo _('Description (max 50 car.)'); ?>
|
||||
<?php echo $description->input();?>
|
||||
</p>
|
||||
|
|
@ -5,12 +5,13 @@
|
|||
<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 $this->jrn_def_id; ?>">
|
||||
<input type="hidden" id="p_jrn" name="p_jrn" value="<?php echo $p_array["p_jrn"]; ?>">
|
||||
<?php echo $str_add_button?>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php echo $f_legend_detail?></legend>
|
||||
<div class="fieldset" style="overflow:auto;max-height:300px">
|
||||
<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>
|
||||
|
|
@ -79,6 +80,6 @@ echo '</tr>';
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue