Merged revisions 3015-3016 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel500 ........ r3015 | danydb | 2010-04-16 12:25:57 +0200 (Fri, 16 Apr 2010) | 5 lines Quick_writing ============= Limit the operation to the ODS ledger and no longer to any ledgers ........ r3016 | danydb | 2010-04-16 12:36:14 +0200 (Fri, 16 Apr 2010) | 8 lines TVA_IPOPUP ========== Add a new widget to let user select a VAT into a POPUP Add javascript to set the label and tva_id Check if TVA is valid (compute.php, acc_ledger.php) ........
This commit is contained in:
parent
e3eb3d7434
commit
9ac52c4ce6
8 changed files with 117 additions and 16 deletions
|
|
@ -128,7 +128,11 @@ EOF;
|
|||
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$row=Database::fetch_array($Res,$i);
|
||||
$script="onclick=\"$('$ctl').value='".$row['tva_id']."';hideIPopup('".$popup."');\"";
|
||||
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."');\"";
|
||||
}
|
||||
$set= '<INPUT TYPE="BUTTON" Value="select" '.$script.'>';
|
||||
$r.='<tr>';
|
||||
$r.=td($set);
|
||||
|
|
@ -141,7 +145,7 @@ EOF;
|
|||
$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"?>
|
||||
|
|
@ -149,6 +153,26 @@ echo <<<EOF
|
|||
<code>$html</code>
|
||||
<popup>$popup</popup>
|
||||
</data>
|
||||
EOF;
|
||||
break;
|
||||
case 'label_tva':
|
||||
$cn=new Database($gDossier);
|
||||
if ( isNumber($id) == 0 )
|
||||
$value = _('tva inconnue');
|
||||
else {
|
||||
$Res=$cn->get_array("select * from tva_rate where tva_id = $1",array($id));
|
||||
if ( count($Res) == 0 )
|
||||
$value=_('tva inconnue');
|
||||
else
|
||||
$value=$Res[0]['tva_label'];
|
||||
}
|
||||
header('Content-type: text/xml; charset=UTF-8');
|
||||
echo <<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<data>
|
||||
<code>$code</code>
|
||||
<value>$value</value>
|
||||
</data>
|
||||
EOF;
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -49,20 +49,16 @@ foreach (array('t','c','p','q','n','gDossier') as $a) {
|
|||
$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"
|
||||
*if the tva_rate->load failed we don't compute tva
|
||||
*/
|
||||
$tva_rate->load();
|
||||
if ( $tva_rate->load() != 0 ) {
|
||||
$tva_rate->set_parameter('rate',0);
|
||||
}
|
||||
}
|
||||
|
||||
$total=new Acc_Compute();
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ function compute_ledger(p_ctl_nb) {
|
|||
var tva_id=-1;
|
||||
if ( g('e_march'+p_ctl_nb+'_tva_id') ) {
|
||||
tva_id=g('e_march'+p_ctl_nb+'_tva_id').value;
|
||||
if ( trim(tva_id) == '') {tva_id=-1;}
|
||||
}
|
||||
|
||||
g('e_march'+p_ctl_nb+'_price').value=trim(g('e_march'+p_ctl_nb+'_price').value);
|
||||
|
|
|
|||
|
|
@ -285,6 +285,8 @@ 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;
|
||||
if ( obj.jcode )
|
||||
queryString+='&code='+obj.jcode;
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php" ,
|
||||
{ method:'get',
|
||||
|
|
@ -312,4 +314,40 @@ function success_popup_select_tva(req) {
|
|||
$(name_ctl).innerHTML=code_html;
|
||||
} catch (e) {alert(e.message);}
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief display the popup with vat and explanation
|
||||
*@param obj with 4 attributes gdossier, ctl,popup and phpsessid
|
||||
*/
|
||||
function set_tva_label(obj) {
|
||||
try {
|
||||
var queryString="PHPSESSID="+obj.phpsessid+"&gDossier="+obj.gDossier+"&op=label_tva"+"&id="+obj.value;
|
||||
if ( obj.jcode )
|
||||
queryString+='&code='+obj.jcode;
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php" ,
|
||||
{ method:'get',
|
||||
parameters:queryString,
|
||||
onFailure:ajax_misc_failure,
|
||||
onSuccess:success_set_tva_label
|
||||
}
|
||||
);
|
||||
} catch (e) {alert(e.message);}
|
||||
}
|
||||
/**
|
||||
*@brief display the popup with vat and explanations
|
||||
*/
|
||||
function success_set_tva_label(req) {
|
||||
try {
|
||||
var answer=req.responseXML;
|
||||
var code=answer.getElementsByTagName('code');
|
||||
var value=answer.getElementsByTagName('value');
|
||||
|
||||
if ( code.length == 0 ) { var rec=req.responseText;alert ('erreur :'+rec);}
|
||||
|
||||
var label_code=code[0].firstChild.nodeValue;
|
||||
var label_value=value[0].firstChild.nodeValue;
|
||||
set_value(label_code,label_value);
|
||||
} catch (e) {alert(e.message);}
|
||||
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ for ($i=0;$i<$Max;$i++) {
|
|||
$row=Database::fetch_array($Res,$i);
|
||||
$set=sprintf( '<INPUT TYPE="BUTTON" Value="select" onClick="GetIt(\'%s\',\'%s\');">',
|
||||
$_GET['ctl'],$row['tva_id']);
|
||||
printf("<tr><TD BGCOLOR=\LIGHTGREEN\" >%s %d</TD><TD>%s</TD><TD>%s</TD></TR>",
|
||||
printf("<tr><TD>%s %d</TD><TD>%s</TD><TD>%s</TD></TR>",
|
||||
$set,
|
||||
$row['tva_id'],
|
||||
$row['tva_label'],
|
||||
|
|
|
|||
|
|
@ -586,6 +586,7 @@ Array
|
|||
// Verify if the rate exists, if not then do not update
|
||||
if ( strlen(trim($value)) != 0 )
|
||||
{
|
||||
if ( isNumber($value) == 0 ) continue;
|
||||
if ( $this->cn->count_sql("select * from tva_rate where tva_id=".$value) == 0)
|
||||
{
|
||||
echo_debug("class_fiche",__LINE__,"Tva invalide $value");
|
||||
|
|
|
|||
|
|
@ -25,24 +25,53 @@
|
|||
*/
|
||||
require_once ('class_ipopup.php');
|
||||
require_once('class_ibutton.php');
|
||||
|
||||
require_once('class_ispan.php');
|
||||
/**
|
||||
*@brief let you choose a TVA in a popup
|
||||
*@code
|
||||
$a=new IPopup('popup_tva');
|
||||
$a->set_title('Choix de la tva');
|
||||
echo $a->input();
|
||||
$tva=new ITva_Popup("tva1");
|
||||
$tva->with_button(true);
|
||||
// We can add a label for the code
|
||||
$tva->add_label('code');
|
||||
$tva->js='onchange="set_tva_label(this);"';
|
||||
echo $tva->input();
|
||||
@endcode
|
||||
*/
|
||||
class ITva_Popup extends HtmlInput
|
||||
{
|
||||
public function __construct($p_name=null) {
|
||||
$this->name=$p_name;
|
||||
$this->button=true;
|
||||
}
|
||||
function with_button($p) {
|
||||
if ($p == true )
|
||||
$this->button=true;
|
||||
else
|
||||
$this->button=false;
|
||||
}
|
||||
|
||||
/*!\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:"";
|
||||
$this->js=(isset($this->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);
|
||||
if ( $this->button==true)
|
||||
$r.=$this->dbutton();
|
||||
|
||||
if ( isset($this->code)){
|
||||
$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;
|
||||
|
||||
}
|
||||
|
|
@ -61,9 +90,13 @@ require_once('class_ibutton.php');
|
|||
$bt->set_attribute('gDossier',dossier::id());
|
||||
$bt->set_attribute('ctl',$this->name);
|
||||
$bt->set_attribute('popup','popup_tva');
|
||||
if ( isset($this->code))
|
||||
$bt->set_attribute('jcode',$this->code->name);
|
||||
$bt->javascript='popup_select_tva(this)';
|
||||
return $bt->input();
|
||||
$r=$bt->input();
|
||||
return $r;
|
||||
}
|
||||
|
||||
/*!\brief print in html the readonly value of the widget*/
|
||||
public function display()
|
||||
{
|
||||
|
|
@ -71,12 +104,19 @@ require_once('class_ibutton.php');
|
|||
$res=sprinf($r,$this->name,$this->value,$this->name);
|
||||
return $res;
|
||||
}
|
||||
public function add_label($p_code) {
|
||||
$this->code=new ISpan($p_code);
|
||||
}
|
||||
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");
|
||||
$tva->with_button(true);
|
||||
// We can add a label for the code
|
||||
$tva->add_label('code');
|
||||
$tva->js='onchange="set_tva_label(this);"';
|
||||
echo $tva->input();
|
||||
echo $tva->dbutton();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ $ledger=new Acc_Ledger($cn,$id);
|
|||
|
||||
$ledger->with_concerned=true;
|
||||
// no ledger selected, propose one
|
||||
// Only ODS
|
||||
if ($id == -1 )
|
||||
{
|
||||
echo '<div class="content">';
|
||||
|
|
@ -140,7 +141,7 @@ if ($id == -1 )
|
|||
echo '<FORM method="get" action="?">';
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::hidden('p_action',$_REQUEST['p_action']);
|
||||
echo $ledger->select_ledger()->input();
|
||||
echo $ledger->select_ledger('ODS',3)->input();
|
||||
echo HtmlInput::submit('show_form',_('Choix du journal'));
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue