===
The select button for VAT has been replaced by a Ipopup, in all the ledgers + gestion
This commit is contained in:
Dany De Bontridder 2010-04-24 19:14:25 +00:00
parent 5e38098c6c
commit f73ff75210
12 changed files with 171 additions and 30 deletions

View file

@ -26,6 +26,11 @@
* - PHPSESSID
* - gDossier
* - $op operation the file has to execute
* Part 1
* dsp_tva fill a ipopup with a choice of possible VAT
* - if code is set then fill the field code
* - if compute is set then add event to call clean_tva and compute_ledger
@Acc_Ledger_Sold::input
*
*/
require_once('class_database.php');
@ -128,11 +133,20 @@ EOF;
for ($i=0;$i<$Max;$i++) {
$row=Database::fetch_array($Res,$i);
if ( ! isset($code)) {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\"";
} else {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');\"";
}
if ( ! isset($compute)) {
if ( ! isset($code) ) {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\"";
} else {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');\"";
}
} else {
if ( ! isset($code) ) {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\"";
} else {
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';set_value('$code','".$row['tva_label']."');hideIPopup('".$popup."');clean_tva('$compute');compute_ledger('$compute');\"";
}
}
$set= '<INPUT TYPE="BUTTON" Value="select" '.$script.'>';
$r.='<tr>';
$r.=td($set);

View file

@ -87,6 +87,8 @@ if ( $action == 'ach' ||
if ( $action == 'fin') {
require_once ('compta_fin.inc.php');
}
if ($action == 'let') {
require_once('letter.inc.php');
}
html_page_stop();
?>

View file

@ -50,7 +50,7 @@ $cn=new Database(dossier::id());
$User=new User($cn);
$User->Check();
// Retrieve the rate of vat, it $t == -1 it means no VAT
if ( $t != -1 ){
if ( $t != -1 && isNumber($t) == 1 ){
$tva_rate=new Acc_Tva($cn);
$tva_rate->set_parameter('id',$t);
/**
@ -65,7 +65,7 @@ $total=new Acc_Compute();
bcscale(4);
$amount=round(bcmul($p,$q),2);
$total->set_parameter('amount',$amount);
if ( $t != -1 ) {
if ( $t != -1 && isNumber($t) == 1 ) {
$total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate'));
$total->compute_vat();
$tvac=bcadd($total->get_parameter('amount_vat'),$amount);

View file

@ -299,6 +299,8 @@ function popup_select_tva(obj) {
var queryString="PHPSESSID="+obj.phpsessid+"&gDossier="+obj.gDossier+"&op=dsp_tva"+"&ctl="+obj.ctl+'&popup='+obj.popup;
if ( obj.jcode )
queryString+='&code='+obj.jcode;
if (obj.compute)
queryString+='&compute='+obj.compute;
var action = new Ajax.Request(
"ajax_misc.php" ,
{ method:'get',

View file

@ -30,6 +30,11 @@
*
*/
echo js_include('gestion.js');
require_once('class_itva_popup.php');
$pop_tva=new IPopup('popup_tva');
$pop_tva->title=_('Choix TVA');
$pop_tva->value='';
echo $pop_tva->input();
$supl_hidden='';
if( isset($_REQUEST['sc']))

View file

@ -38,6 +38,8 @@ require_once('user_common.php');
require_once('class_acc_parm_code.php');
require_once('class_acc_payment.php');
require_once('ac_common.php');
require_once('class_itva_popup.php');
/*!\brief Handle the ledger of purchase,
*
*
@ -156,6 +158,15 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
if ( isNumber(${'e_quant'.$i}) == 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a une quantité invalide').' ['.${'e_quant'.$i}.']',7);
// Check if the given tva id is valid
if ( isNumber(${'e_march'.$i.'_tva_id'}) == 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un code tva invalide').' ['.${'e_march'.$i.'_tva_id'}.']',13);
$tva_rate=new Acc_Tva($this->db);
$tva_rate->set_parameter('id',${'e_march'.$i.'_tva_id'});
if ( $tva_rate->load() != 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un code tva invalide').' ['.${'e_march'.$i.'_tva_id'}.']',13);
/* check if all card has a ATTR_DEF_ACCOUNT*/
$fiche=new fiche($this->db);
$fiche->get_by_qcode(${'e_march'.$i});
@ -186,6 +197,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
}
if ( $nb == 0 )
throw new Exception(_('Il n\'y a aucune marchandise'),12);
}
public function save($p_array) {
@ -928,9 +940,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
// vat label
//--
$Tva=new ITva_Select($this->db);
$Tva->javascript="onChange=clean_tva($i);compute_ledger($i)";
$Tva->selected=$march_tva_id;
$Tva=new ITva_Popup($this->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

View file

@ -38,6 +38,7 @@ require_once('user_common.php');
require_once('class_acc_payment.php');
require_once('ac_common.php');
require_once('class_own.php');
require_once('class_itva_popup.php');
/*!\brief Handle the ledger of sold,
*
@ -150,10 +151,20 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$fiche->get_by_qcode(${'e_march'.$i});
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
// Check if the given tva id is valid
if ( isNumber(${'e_march'.$i.'_tva_id'}) == 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un code tva invalide').' ['.${'e_march'.$i.'_tva_id'}.']',13);
$tva_rate=new Acc_Tva($this->db);
$tva_rate->set_parameter('id',${'e_march'.$i.'_tva_id'});
if ( $tva_rate->load() != 0 )
throw new Exception(_('La fiche ').${'e_march'.$i}._('a un code tva invalide').' ['.${'e_march'.$i.'_tva_id'}.']',13);
// if 2 accounts, take only the credit one
/* The account exists */
$sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
// if 2 accounts, take only the credit one
if ( strpos($sposte,',') != 0 ) {
$array=explode(',',$sposte);
$poste_val=$array[1];
@ -559,8 +570,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$r.="<th>"._('Code')."</th>";
$r.="<th>"._('Dénomination')."</th>";
$r.="<th>"._('prix')."</th>";
$r.="<th>"._('tva')."</th>";
$r.="<th>"._('quantité')."</th>";
$r.="<th>"._('tva')."</th>";
if ( $own->MY_TVA_USE=='Y') {
$r.='<th> '._('Montant TVA').'</th>';
@ -1068,9 +1080,12 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ( $flag_tva == 'Y' ) {
// vat label
//--
$Tva=new ITva_Select($this->db);
$Tva->javascript="onChange=clean_tva($i);compute_ledger($i)";
$Tva->selected=$march_tva_id;
$Tva=new ITva_Popup($this->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
//--

View file

@ -401,7 +401,8 @@ class Action
$num=new INum();
/* TVA */
$itva=new ITva_Select($this->db);
$itva=new ITva_Popup($this->db);
$itva->in_table=true;
/* create aArticle for the detail section */
for ($i=0;$i< MAX_ARTICLE;$i++) {
@ -453,7 +454,9 @@ class Action
$itva->name='e_march'.$i.'_tva_id';
$itva->value=($tmp_ad)?$tmp_ad->get_parameter('tva_id'):0;
$itva->javascript=' onchange="clean_tva('.$i.');compute_ledger('.$i.')"';
$itva->javascript=' onchange="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"';
$itva->set_attribute('compute',$i);
$aArticle[$i]['tvaid']=$itva->input();
$num->name="e_march".$i."_tva_amount";

View file

@ -34,6 +34,11 @@ require_once('class_ispan.php');
echo $a->input();
$tva=new ITva_Popup("tva1");
$tva->with_button(true);
// You must add the attributes gDossier, popup and phpsessid
$tva->set_attribute('popup','popup_tva');
$tva->set_attribute('phpsessid',$_REQUEST['PHPSESSID']);
$tva->set_attribute('gDossier',dossier::id());
// We can add a label for the code
$tva->add_label('code');
$tva->js='onchange="set_tva_label(this);"';
@ -42,9 +47,19 @@ require_once('class_ispan.php');
*/
class ITva_Popup extends HtmlInput
{
/**
*@brief by default, the p_name is the name/id of the input type
* the this->button is false (control if a button is visible) and
* this->in_table=false (return the widget inside a table)
* this->code is a span widget to display the code (in this case, you will
* to set this->cn as database connexion)
* to have its own javascript for the button you can use this->but_javascript)
* by default it is 'popup_select_tva(this)';
*/
public function __construct($p_name=null) {
$this->name=$p_name;
$this->button=true;
$this->in_table=false;
}
function with_button($p) {
if ($p == true )
@ -57,14 +72,21 @@ require_once('class_ispan.php');
{
$this->name=($p_name==null)?$this->name:$p_name;
$this->value=($p_value==null)?$this->value:$p_value;
$this->js=(isset($this->js))?$this->js:"";
$this->js=(isset($this->js))?$this->js:"format_number(this);";
if ( $this->readOnly==true) return $this->display();
$str='<input type="TEXT" name="%s" value="%s" id="%s" size="3" "%s">';
$r=sprintf($str,$this->name,$this->value,$this->name,$this->js);
if ( $this->button==true)
if ($this->in_table)
$table='<table>'.'<tr>'.td($r);
if ( $this->button==true && ! $this->in_table)
$r.=$this->dbutton();
if ( $this->button==true && $this->in_table)
$r=$table.td($this->dbutton()).'</tr></table>';
if ( isset($this->code)){
if ( $this->cn != NULL){
/* check if tva_id == integer */
@ -73,15 +95,17 @@ require_once('class_ispan.php');
array($this->value));;
}
$r.=$this->code->input();
$this->set_attribute('jcode',$this->code->name);
$this->set_attribute('gDossier',dossier::id());
$this->set_attribute('ctl',$this->name);
$r.=$this->get_js_attr();
}
return $r;
$this->set_attribute('jcode',$this->code->name);
$this->set_attribute('gDossier',dossier::id());
$this->set_attribute('ctl',$this->name);
$r.=$this->get_js_attr();
}
return $r;
}
/**
*@brief show a button, if it is pushed show a popup to select the need vat
*@note
@ -99,7 +123,9 @@ require_once('class_ispan.php');
$bt->set_attribute('popup','popup_tva');
if ( isset($this->code))
$bt->set_attribute('jcode',$this->code->name);
$bt->javascript='popup_select_tva(this)';
if ( isset($this->compute))
$bt->set_attribute('compute',$this->compute);
$bt->javascript=(isset($this->but_javascript))?$this->but_javascript:'popup_select_tva(this)';
$r=$bt->input();
return $r;
}

View file

@ -45,7 +45,10 @@ $search_card=new IPopup('ipop_card');
$search_card->title=_('Recherche de fiche');
$search_card->value='';
echo $search_card->input();
$pop_tva=new IPopup('popup_tva');
$pop_tva->title=_('Choix TVA');
$pop_tva->value='';
echo $pop_tva->input();
$p_action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:'';
$cn=new Database(dossier::id());

View file

@ -46,6 +46,11 @@ $search_card->title=_('Recherche de fiche');
$search_card->value='';
echo $search_card->input();
$pop_tva=new IPopup('popup_tva');
$pop_tva->title=_('Choix TVA');
$pop_tva->value='';
echo $pop_tva->input();
$p_action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:'';
$gDossier=dossier::id();
$cn=new Database(dossier::id());

52
include/letter.inc.php Normal file
View file

@ -0,0 +1,52 @@
<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*!\file
* \brief file to include for the "lettrage" (lettering?)
*/
$array=array(
array('?'.dossier::get().'&p_action=let&sa=poste',_('Par poste'),
_('Lettrage par poste'), 1),
array('?'.dossier::get().'&p_action=let&sa=qc',_('Par fiche'),
_('Lettrage par fiche'), 2)
);
$sa=(isset($_REQUEST['sa']))?$_REQUEST['sa']:0;
switch($sa){
case 'poste':
$subdef=1;
break;
case 'qc':
$subdef=2;
break;
}
echo '<div class="lmenu">';
echo ShowItem($array,'H','mtitle','mtitle',$subdef);
echo '</div>';
if ($sa == 'poste') {
require_once('lettering.account.inc.php');
exit;
}
if ($sa=='qc') {
exit;
}