[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r268 - in trunk/coprop: . include include/template
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r268 - in trunk/coprop: . include include/template |
Date: |
Sun, 8 Jan 2012 00:01:25 +0100 (CET) |
Author: danydb
Date: 2012-01-08 00:01:25 +0100 (Sun, 08 Jan 2012)
New Revision: 268
Added:
trunk/coprop/include/template/budget.php
Modified:
trunk/coprop/ajax.php
trunk/coprop/coprop-constant.php
trunk/coprop/coprop-javascript.js
trunk/coprop/include/ajax_bud_display.php
trunk/coprop/include/budget.inc.php
trunk/coprop/include/class_budget.php
trunk/coprop/include/template/bud_detail.php
Log:
Budget : fix form + compute total
Modified: trunk/coprop/ajax.php
===================================================================
--- trunk/coprop/ajax.php 2012-01-07 22:44:15 UTC (rev 267)
+++ trunk/coprop/ajax.php 2012-01-07 23:01:25 UTC (rev 268)
@@ -7,14 +7,6 @@
$html='';$extra='';$ctl='';
switch ($act)
{
- // ajout un lien copro + lot
- case 'modcopro':
- /* the hide button */
- require_once('include/ajax_mod_copro_lot.php');
- break;
- case 'removelot':
- $cn->exec_sql("delete from coprop.lot where
l_id=$1",array($lot_id));
- break;
case 'addkey':
require_once 'include/ajax_add_key.php';
break;
Modified: trunk/coprop/coprop-constant.php
===================================================================
--- trunk/coprop/coprop-constant.php 2012-01-07 22:44:15 UTC (rev 267)
+++ trunk/coprop/coprop-constant.php 2012-01-07 23:01:25 UTC (rev 268)
@@ -14,5 +14,5 @@
$gDossier=Dossier::id();
$g_copro_parameter=new Copro_Parameter();
define ("COPRO_MAX_LOT",19);
-
+define("MAXROWBUD",15);
?>
\ No newline at end of file
Modified: trunk/coprop/coprop-javascript.js
===================================================================
--- trunk/coprop/coprop-javascript.js 2012-01-07 22:44:15 UTC (rev 267)
+++ trunk/coprop/coprop-javascript.js 2012-01-07 23:01:25 UTC (rev 268)
@@ -233,9 +233,9 @@
if ( ! isNaN($('cr_tantieme').value)) {
var difference=parseFloat($('cr_tantieme').value)-tot;
if ( difference != 0 ) {
- $('span_diff').style.color="red";
+
$('span_diff').style.backgroundColor="red";
} else {
- $('span_diff').style.color="green";
+
$('span_diff').style.backgroundColor="green";
}
$('span_diff').innerHTML=difference;
}
@@ -268,7 +268,7 @@
}
catch(e)
{
- alert("Réponse Ajax ="+e.message);
+ alert("Réponse Ajax ="+e.message);
}
}
}
@@ -278,4 +278,37 @@
{
alert(e.message);
}
-}
\ No newline at end of file
+}
+function compute_budget()
+{
+ try
+ {
+ str="";
+ var array=$("fbud_update").getInputs('text');
+ var tot=0;
+ for (i=0;i<array.length;i++)
+ {
+ if ( array[i].name.search(/bt_amount/) > -1)
+ {
+ if (! isNaN(array[i].value) &&
array[i].value!= "") {
+ tot+=parseFloat(array[i].value);
+ }
+ }
+ }
+ $("sbud_total").innerHTML=Math.round(tot);
+ if ( ! isNaN($('b_amount').value)) {
+ var difference=parseFloat($('b_amount').value)-tot;
+ if ( difference != 0 ) {
+
$('span_diff').style.backgroundColor="red";
+ } else {
+
$('span_diff').style.backgroundColor="green";
+ }
+ $('span_diff').innerHTML=difference;
+ }
+
+ }
+ catch(e)
+ {
+ alert(e.message);
+ }
+}
Modified: trunk/coprop/include/ajax_bud_display.php
===================================================================
--- trunk/coprop/include/ajax_bud_display.php 2012-01-07 22:44:15 UTC (rev
267)
+++ trunk/coprop/include/ajax_bud_display.php 2012-01-07 23:01:25 UTC (rev
268)
@@ -6,6 +6,8 @@
$bud=new Budget();
$bud->b_id=$bud_id;
-
+echo '<form id="fbud_update" method="post">';
$bud->detail();
+echo HtmlInput::submit("bud_update","Valider");
+echo "</form>";
?>
Modified: trunk/coprop/include/budget.inc.php
===================================================================
--- trunk/coprop/include/budget.inc.php 2012-01-07 22:44:15 UTC (rev 267)
+++ trunk/coprop/include/budget.inc.php 2012-01-07 23:01:25 UTC (rev 268)
@@ -5,10 +5,14 @@
*/
require_once 'class_budget.php';
+$bud=new Budget();
+if ( isset ($_POST['budget_update']))
+{
+ $bud->save();
+}
-$bud=new Budget();
$bud->to_list();
\ No newline at end of file
Modified: trunk/coprop/include/class_budget.php
===================================================================
--- trunk/coprop/include/class_budget.php 2012-01-07 22:44:15 UTC (rev
267)
+++ trunk/coprop/include/class_budget.php 2012-01-07 23:01:25 UTC (rev
268)
@@ -18,6 +18,38 @@
require_once 'template/budget_list.php';
}
+ function load()
+ {
+ global $cn;
+ try
+ {
+ if ($this->b_id == '') throw new Exception("Aucun
budget demandé");
+ $array=$cn->get_array("select
b_id,b_name,b_start,b_end,b_amount,
+ to_char(b_start,'DD.MM.YYYY') as str_b_start,
+ to_char(b_end,'DD.MM.YYYY') as str_b_end
+ from coprop.budget where
b_id=$1",array($this->b_id));
+ if ($cn->count() == 1)
+ {
+ $this->b_name=$array[0]['b_name'];
+ $this->b_start=$array[0]['b_start'];
+ $this->str_b_start=$array[0]['str_b_start'];
+ $this->b_end=$array[0]['b_end'];
+ $this->str_b_end=$array[0]['str_b_end'];
+ $this->b_amount=$array[0]['b_amount'];
+ }
+ else
+ throw new Exception ('Aucun budget trouvé');
+ } catch (Exception $e)
+ {
+ echo $e->getTraceAsString();
+ throw $e;
+ }
+ }
+ /**
+ *Detail d'un budget avec les détails, pour mettre à jour
+ * @global type $cn
+ * @throws Exception
+ */
function detail()
{
global $cn;
@@ -26,6 +58,28 @@
if ( ! isset ($this->b_id)|| trim($this->b_id)=='')
throw new Exception ("Aucun budget demandé");
+ $this->load();
+ $name=new IText('b_name');
+ if ($this->b_id <> 0)
+ {
+ $name->value=$this->b_name;
+ $start=new IDate('b_start',$this->str_b_start);
+ $end=new IDate('b_end',$this->str_b_end);
+ $amount=new
INum('b_amount',round($this->b_amount,2));
+
+ } else {
+ $start=new IDate('b_start');
+ $end=new IDate('b_end');
+ $amount=new INum('b_amount',0);
+
+ }
+
$amount->javascript='onchange="format_number(this,2);compute_budget();"';
+ $bud_amount=$amount->value;
+
+ echo HtmlInput::hidden("b_id",$this->b_id);
+ echo
HtmlInput::request_to_hidden(array('gDossier','ac','plugin_code','sa'));
+ require_once 'template/budget.php';
+
$array=$cn->get_array("select
bt_id,bt_amount,f_id,vw_name,quick_code,cr_name,cr_id
from coprop.budget_detail
join coprop.clef_repartition using (cr_id)
@@ -35,10 +89,11 @@
$fiche_dep=$cn->make_list("select fd_id from fiche_def where
frd_id=2");
$a_key=$cn->make_array(" select cr_id,cr_name from
coprop.clef_repartition order by cr_name");
- for ($i=0;$i<count($array);$i++)
+ $max=count($array);
+ for ($i=0;$i<MAXROWBUD;$i++)
{
$card=new ICard('f_id'.$i);
- $card->value=$array[$i]['quick_code'];
+ $card->value=($i>=$max)?"":$array[$i]['quick_code'];
$card->table=0;
// name of the field to update with the name of the card
@@ -69,12 +124,13 @@
$f_card_bt=$card->search();
$amount=new INum("bt_amount[]");
- $amount->value=round($array[$i]['bt_amount'],2);
- $hidden=HtmlInput::hidden("bt_id[]",$array[$i]["bt_id"]);
+ $amount->value=($i>=$max)?"":round($array[$i]['bt_amount'],2);
+
$amount->javascript='onchange="format_number(this,2);compute_budget();"';
+
$hidden=($i>=$max)?0:HtmlInput::hidden("bt_id[]",$array[$i]["bt_id"]);
$ikey=new ISelect("key[]");
$ikey->value=$a_key;
- $ikey->selected=$array[$i]['cr_id'];
+ $ikey->selected=($i>=$max)?0:$array[$i]['cr_id'];
$a_input[$i]["amount"]=$amount->input();
$a_input[$i]["hidden"]=$hidden;
Modified: trunk/coprop/include/template/bud_detail.php
===================================================================
--- trunk/coprop/include/template/bud_detail.php 2012-01-07 22:44:15 UTC
(rev 267)
+++ trunk/coprop/include/template/bud_detail.php 2012-01-07 23:01:25 UTC
(rev 268)
@@ -24,15 +24,21 @@
</td>
<td>
<?=$a_input[$i]['key']?>
-
+
</td>
-
+
<td>
<?=$a_input[$i]['amount']?>
-
+
</td>
- </tr>
-
+ </tr>
+
<? endfor?>
-
+
</table>
+<p>
+ Total <span id="sbud_total"><?=nbm($bud_amount)?></span>
+</p>
+<p>
+Différence <span id="span_diff"></span>
+</p>
\ No newline at end of file
Added: trunk/coprop/include/template/budget.php
===================================================================
--- trunk/coprop/include/template/budget.php (rev 0)
+++ trunk/coprop/include/template/budget.php 2012-01-07 23:01:25 UTC (rev
268)
@@ -0,0 +1,65 @@
+<?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 address@hidden
+
+/**
+ * @file
+ * @brief show budget header
+ * @see Budget::detail
+ *
+ */
+?>
+<table>
+ <tr>
+ <td>
+ Nom
+ </td>
+ <td>
+ <?=$name->input()?>
+ </td
+ </tr>
+ <tr>
+ <td>
+ Date début
+ </td>
+ <td>
+ <?=$start->input()?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Date fin
+ </td>
+ <td>
+ <?=$end->input()?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Montant
+ </td>
+ <td>
+ <?=$amount->input()?>
+ </td>
+
+ </tr>
+</table>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r268 - in trunk/coprop: . include include/template,
phpcompta-dev <=