Merged revisions 3001-3012 via svnmerge from
file:///home/developper/svn/phpcompta/branches/rel500 ........ r3007 | danydb | 2010-04-12 23:31:21 +0200 (Mon, 12 Apr 2010) | 4 lines Use ITva_Select in class_acc_legder_purchase.php ........ r3008 | danydb | 2010-04-13 00:58:43 +0200 (Tue, 13 Apr 2010) | 8 lines TVA Ipopup ========== Add a new widget which show the tva in a popup and let it select the code you need it will replace the obsolete TVA_Select ........ r3009 | danydb | 2010-04-13 20:15:59 +0200 (Tue, 13 Apr 2010) | 4 lines Todo : add the todo for the use of the new widget Tva_Popup ........ r3010 | danydb | 2010-04-14 18:58:56 +0200 (Wed, 14 Apr 2010) | 1 line Add a new function in class periode : last_day ........ r3011 | danydb | 2010-04-14 19:00:09 +0200 (Wed, 14 Apr 2010) | 1 line Add a new function in class periode : last_day correct typo ........
This commit is contained in:
parent
4714027677
commit
9c2e1427c2
11 changed files with 225 additions and 23 deletions
|
|
@ -113,5 +113,43 @@ echo <<<EOF
|
|||
EOF;
|
||||
return;
|
||||
break;
|
||||
case 'dsp_tva':
|
||||
$cn=new Database($gDossier);
|
||||
$Res=$cn->exec_sql("select * from tva_rate order by tva_rate desc");
|
||||
$Max=Database::num_row($Res);
|
||||
$r="";
|
||||
$r='<div style="margin-left:10%;margin-right:10%">';
|
||||
$r= "<TABLE BORDER=\"1\">";
|
||||
$r.=th('');
|
||||
$r.=th(_('code'));
|
||||
$r.=th(_('Taux'));
|
||||
$r.=th(_('Symbole'));
|
||||
$r.=th(_('Explication'));
|
||||
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$row=Database::fetch_array($Res,$i);
|
||||
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\"";
|
||||
$set= '<INPUT TYPE="BUTTON" Value="select" '.$script.'>';
|
||||
$r.='<tr>';
|
||||
$r.=td($set);
|
||||
$r.=td($row['tva_id']);
|
||||
$r.=td($row['tva_rate']);
|
||||
$r.=td($row['tva_label']);
|
||||
$r.=td($row['tva_comment']);
|
||||
$r.='</tr>';
|
||||
}
|
||||
$r.='</TABLE>';
|
||||
$r.='</div>';
|
||||
$html=escape_xml($r);
|
||||
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo <<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<data>
|
||||
<code>$html</code>
|
||||
<popup>$popup</popup>
|
||||
</data>
|
||||
EOF;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,18 @@ $cn=new Database(dossier::id());
|
|||
$User=new User($cn);
|
||||
$User->Check();
|
||||
|
||||
/**
|
||||
*@todo check with my_own if the vat must be computed instead of
|
||||
*a special value
|
||||
*/
|
||||
// Retrieve the rate of vat, it $t == -1 it means no VAT
|
||||
if ( $t != -1 ){
|
||||
$tva_rate=new Acc_Tva($cn);
|
||||
$tva_rate->set_parameter('id',$t);
|
||||
/**
|
||||
*@todo if the tva_rate->load failed we have to return an
|
||||
*error message "invalid tva"
|
||||
*/
|
||||
$tva_rate->load();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,6 +184,9 @@ function compute_ledger(p_ctl_nb) {
|
|||
var qcode=g("e_march"+p_ctl_nb).value;
|
||||
|
||||
if ( qcode.length == 0 ) { clean_ledger(p_ctl_nb);refresh_ledger();return;}
|
||||
/**
|
||||
*@todo if tva_id is empty send a value of -1
|
||||
*/
|
||||
var tva_id=-1;
|
||||
if ( g('e_march'+p_ctl_nb+'_tva_id') ) {
|
||||
tva_id=g('e_march'+p_ctl_nb+'_tva_id').value;
|
||||
|
|
@ -223,12 +226,16 @@ function refresh_ledger() {
|
|||
if (g('tvac')) g('tvac').innerHTML=Math.round(tvac*100)/100;
|
||||
}
|
||||
/**
|
||||
* @brief update the field htva, tva_id and tvac, callback function for compute_sold
|
||||
*@brief update the field htva, tva_id and tvac, callback function for compute_sold
|
||||
* it the field TVA in the answer contains NA it means that VAT is appliable and then do not
|
||||
* update the VAT field except htva_martc
|
||||
*/
|
||||
function success_compute_ledger(request,json) {
|
||||
|
||||
/**
|
||||
*@todo add a control
|
||||
* - 0 everything is ok
|
||||
* - 1 tva id is invalid
|
||||
*/
|
||||
var answer=request.responseText.evalJSON(true);
|
||||
var ctl=answer.ctl;
|
||||
var rtva=answer.tva;
|
||||
|
|
|
|||
|
|
@ -276,4 +276,40 @@ function success_cat_doc_remove(req) {
|
|||
$('X'+row_id).style.display='none';
|
||||
}
|
||||
catch (e) { alert(e.message);}
|
||||
}
|
||||
/**
|
||||
*@brief display the popup with vat and explanation
|
||||
*@param obj with 4 attributes gdossier, ctl,popup and phpsessid
|
||||
*/
|
||||
function popup_select_tva(obj) {
|
||||
try {
|
||||
showIPopup(obj.popup);
|
||||
var queryString="PHPSESSID="+obj.phpsessid+"&gDossier="+obj.gDossier+"&op=dsp_tva"+"&ctl="+obj.ctl+'&popup='+obj.popup;
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php" ,
|
||||
{ method:'get',
|
||||
parameters:queryString,
|
||||
onFailure:ajax_misc_failure,
|
||||
onSuccess:success_popup_select_tva
|
||||
}
|
||||
);
|
||||
} catch (e) {alert(e.message);}
|
||||
}
|
||||
/**
|
||||
*@brief display the popup with vat and explanations
|
||||
*/
|
||||
function success_popup_select_tva(req) {
|
||||
try {
|
||||
var answer=req.responseXML;
|
||||
var popup=answer.getElementsByTagName('popup');
|
||||
if ( popup.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);}
|
||||
var html=answer.getElementsByTagName('code');
|
||||
|
||||
var name_ctl=popup[0].firstChild.nodeValue+'_content';
|
||||
var nodeXml=html[0];
|
||||
var code_html=getNodeText(nodeXml);
|
||||
code_html=unescape_xml(code_html);
|
||||
$(name_ctl).innerHTML=code_html;
|
||||
} catch (e) {alert(e.message);}
|
||||
|
||||
}
|
||||
|
|
@ -564,7 +564,7 @@ div.popup_border_title {
|
|||
/*background:lightgrey;*/
|
||||
z-index:10;
|
||||
/*border:dotted 1px black;*/
|
||||
border: 3px groove black;
|
||||
border: 3px groove lightblue;
|
||||
background-color:#879ED4;
|
||||
font-size: 110% ;
|
||||
font-family: arial,sans-serif;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ $array=array(
|
|||
array(25,'Search Ledger'),
|
||||
array(26,'Gettext'),
|
||||
array(27,'Card (class_fiche)'),
|
||||
array(28,'Extension')
|
||||
array(28,'Extension'),
|
||||
array(29,'ITVA popup')
|
||||
);
|
||||
$r='<form method="get">';
|
||||
$r.='<select name="test_select" >';
|
||||
|
|
@ -227,7 +228,18 @@ case 28:
|
|||
require_once('class_extension.php');
|
||||
Extension::test_me();
|
||||
break;
|
||||
|
||||
case 29:
|
||||
require_once('class_itva_popup.php');
|
||||
echo JS_PROTOTYPE;
|
||||
echo JS_AJAX_FICHE;
|
||||
echo JS_CARD;
|
||||
echo js_include('scripts.js');
|
||||
echo js_include('scriptaculous.js');
|
||||
echo js_include('effects.js');
|
||||
echo js_include("controls.js");
|
||||
echo js_include('dragdrop.js');
|
||||
ITva_Popup::test_me();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
|
|||
*\param an array (usually $_POST)
|
||||
*\return String
|
||||
*\throw Exception if an error occurs
|
||||
*\todo verify also the vat
|
||||
*/
|
||||
public function verify($p_array) {
|
||||
extract ($p_array);
|
||||
|
|
@ -124,7 +125,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
|
|||
if ( $poste->load() == false ){
|
||||
throw new Exception(_('Pour la fiche ').$e_client._(' le poste comptable [').$poste->id.'] '._('n\'existe pas'),9);
|
||||
}
|
||||
|
||||
/**
|
||||
*@todo we have to check also the different accounting
|
||||
define ("ATTR_DEF_DEP_PRIV",31);
|
||||
define ("ATTR_DEF_DEPENSE_NON_DEDUCTIBLE",20);
|
||||
define ("ATTR_DEF_TVA_NON_DEDUCTIBLE",21);
|
||||
define ("ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP",22);
|
||||
*/
|
||||
/* Check if the card belong to the ledger */
|
||||
$fiche=new fiche ($this->db);
|
||||
$fiche->get_by_qcode($e_client,'cred');
|
||||
|
|
@ -921,11 +928,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
|
|||
|
||||
// vat label
|
||||
//--
|
||||
$select_tva=$this->db->make_array("select tva_id,tva_label from tva_rate order by tva_rate desc",0);
|
||||
$Tva=new ISelect();
|
||||
$Tva->javascript="onChange=\"clean_tva($i);compute_ledger($i);\"";
|
||||
$Tva=new ITva_Select($this->db);
|
||||
$Tva->javascript="onChange=clean_tva($i);compute_ledger($i)";
|
||||
$Tva->selected=$march_tva_id;
|
||||
$array[$i]['tva']=$Tva->input("e_march$i"."_tva_id",$select_tva);
|
||||
$array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
|
||||
|
||||
// Tva_amount
|
||||
|
||||
// price
|
||||
|
|
@ -979,6 +986,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
|
|||
*\param array contains normally $_POST. It proposes also to save
|
||||
* the Analytic accountancy
|
||||
*\return string
|
||||
*\todo verify also the vat
|
||||
*/
|
||||
function confirm($p_array) {
|
||||
extract ($p_array);
|
||||
|
|
|
|||
|
|
@ -509,6 +509,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
|
|||
*\param array contains normally $_POST. It proposes also to save
|
||||
* the Analytic accountancy
|
||||
*\return string
|
||||
*\todo verify also the vat
|
||||
*/
|
||||
function confirm($p_array) {
|
||||
extract ($p_array);
|
||||
|
|
|
|||
83
include/class_itva_popup.php
Normal file
83
include/class_itva_popup.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?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: 1615 $ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief Html Input
|
||||
*/
|
||||
require_once ('class_ipopup.php');
|
||||
require_once('class_ibutton.php');
|
||||
|
||||
class ITva_Popup extends HtmlInput
|
||||
{
|
||||
public function __construct($p_name=null) {
|
||||
$this->name=$p_name;
|
||||
}
|
||||
|
||||
/*!\brief show the html input of the widget*/
|
||||
public function input($p_name=null,$p_value=null)
|
||||
{
|
||||
$this->name=($p_name==null)?$this->name:$p_name;
|
||||
$this->value=($p_value==null)?$this->value:$p_value;
|
||||
$this->js=(isset($p_js))?$this->js:"";
|
||||
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);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief show a button, if it is pushed show a popup to select the need vat
|
||||
*@note
|
||||
* - a ipopup must be created before with the name popup_tva
|
||||
* - the javascript scripts.js must be loaded
|
||||
*@return string with html code
|
||||
*/
|
||||
function dbutton() {
|
||||
if( trim($this->name)=='') throw new Exception (_('Le nom ne peut être vide'));
|
||||
// button
|
||||
$bt=new IButton('bt_'.$this->name);
|
||||
$bt->label=_('tva');
|
||||
$bt->set_attribute('gDossier',dossier::id());
|
||||
$bt->set_attribute('ctl',$this->name);
|
||||
$bt->set_attribute('popup','popup_tva');
|
||||
$bt->javascript='popup_select_tva(this)';
|
||||
return $bt->input();
|
||||
}
|
||||
/*!\brief print in html the readonly value of the widget*/
|
||||
public function display()
|
||||
{
|
||||
$r='<input text name="%s" value="%s" id="%s" disabled>';
|
||||
$res=sprinf($r,$this->name,$this->value,$this->name);
|
||||
return $res;
|
||||
}
|
||||
static public function test_me()
|
||||
{
|
||||
$a=new IPopup('popup_tva');
|
||||
$a->set_title('Choix de la tva');
|
||||
echo $a->input();
|
||||
$tva=new ITva_Popup("tva1");
|
||||
echo $tva->input();
|
||||
echo $tva->dbutton();
|
||||
}
|
||||
}
|
||||
|
|
@ -336,13 +336,22 @@ $ret['p_end']=>'31.01.2009'
|
|||
|
||||
}
|
||||
/*!\brief return the first day of periode
|
||||
*the this->p_id must be said
|
||||
*\return a string with the date (DD.MM.YYYY)
|
||||
*/
|
||||
*the this->p_id must be set
|
||||
*\return a string with the date (DD.MM.YYYY)
|
||||
*/
|
||||
public function first_day() {
|
||||
list($p_start,$p_end)=$this->get_date_limit($this->p_id);
|
||||
return $p_start;
|
||||
}
|
||||
/*!\brief return the last day of periode
|
||||
*the this->p_id must be set
|
||||
*\return a string with the date (DD.MM.YYYY)
|
||||
*/
|
||||
public function last_day() {
|
||||
list($p_start,$p_end)=$this->get_date_limit($this->p_id);
|
||||
return $p_end;
|
||||
}
|
||||
|
||||
function get_exercice($p_id=0) {
|
||||
if ( $p_id == 0 ) $p_id=$this->p_id;
|
||||
$sql="select p_exercice from parm_periode where p_id=".$p_id;
|
||||
|
|
|
|||
|
|
@ -42,12 +42,8 @@ echo '<div class="content">';
|
|||
|| isset ($_POST['confirm_add']))
|
||||
{
|
||||
extract($_POST);
|
||||
$tva_label=FormatString($tva_label);
|
||||
$tva_rate=FormatString($tva_rate);
|
||||
$tva_comment=FormatString($tva_comment);
|
||||
$tva_poste=FormatString($tva_poste);
|
||||
// remove space
|
||||
$tva_poste=str_replace (" ","",$tva_poste);
|
||||
// remove space
|
||||
$tva_poste=str_replace (" ","",$tva_poste);
|
||||
$err=0; // Error code
|
||||
|
||||
if ( isNumber($tva_rate) == 0 ) {
|
||||
|
|
@ -74,6 +70,10 @@ echo '<div class="content">';
|
|||
$Res=$cn->exec_sql(
|
||||
"select tva_modify($tva_id,'$tva_label',
|
||||
'$tva_rate','$tva_comment','$tva_poste')");
|
||||
$Res=$cn->exec_sql(
|
||||
"select tva_modify($1,$2,$3,$4,$5)",
|
||||
array($tva_id,$tva_label,$tva_rate,$tva_comment,$tva_poste)
|
||||
);
|
||||
$err=Database::fetch_result($Res);
|
||||
}
|
||||
|
||||
|
|
@ -231,11 +231,11 @@ if ( ! isset ($_POST['add'])
|
|||
</tr>
|
||||
<tr>
|
||||
<td align="right"> Commentaire </td>
|
||||
<td> <?php $w=new ITextarea; $w->heigh=2;$w->width=20;echo $w->input('tva_comment','') ?></td>
|
||||
<td> <?php $w=new ITextarea; $w->heigh=5;$w->width=50;echo $w->input('tva_comment','') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Poste comptable utilisés format :debit,credit</td>
|
||||
<td> <?php $w=new IText(); $w->size=10;echo $w->input('tva_poste','') ?></td>
|
||||
<td> <?php $w=new IText(); $w->size=20;echo $w->input('tva_poste','') ?></td>
|
||||
</Tr>
|
||||
</table>
|
||||
<input type="submit" value="Confirme" name="confirm_add">
|
||||
|
|
@ -267,13 +267,13 @@ if ( ! isset ($_POST['add'])
|
|||
</tr>
|
||||
<tr>
|
||||
<td align="right"> Commentaire </td>
|
||||
<td> <?php $w=new ITextarea(); $w->heigh=2;$w->width=20;
|
||||
<td> <?php $w=new ITextarea(); $w->heigh=5;$w->width=50;
|
||||
echo $w->input('tva_comment',$tva_array[$index]['tva_comment']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Poste comptable utilisés format :debit,credit</td>
|
||||
|
||||
<td> <?php $w=new IText();$w->size=5; echo $w->input('tva_poste',$tva_array[$index]['tva_poste']) ?></td>
|
||||
<td> <?php $w=new IText();$w->size=20; echo $w->input('tva_poste',$tva_array[$index]['tva_poste']) ?></td>
|
||||
</Tr>
|
||||
</table>
|
||||
<input type="submit" value="Confirme" name="confirm_mod">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue