phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4846 - in phpcompta/trunk: html html/js include include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4846 - in phpcompta/trunk: html html/js include include/template sql
Date: Mon, 28 May 2012 02:44:51 +0200 (CEST)

Author: danydb
Date: 2012-05-28 02:44:49 +0200 (Mon, 28 May 2012)
New Revision: 4846

Modified:
   phpcompta/trunk/html/js/gestion.js
   phpcompta/trunk/html/show_document.php
   phpcompta/trunk/include/action.common.inc.php
   phpcompta/trunk/include/action.inc.php
   phpcompta/trunk/include/class_follow_up.php
   phpcompta/trunk/include/class_html_input.php
   phpcompta/trunk/include/template/detail-action.php
   phpcompta/trunk/sql/upgrade.sql
Log:
Add action :
concerned operation
Cosmetic
removal of operation or comment
Return button, problem with ag_dest (missmatch with the value in the form and 
return button)

Modified: phpcompta/trunk/html/js/gestion.js
===================================================================
--- phpcompta/trunk/html/js/gestion.js  2012-05-27 22:57:08 UTC (rev 4845)
+++ phpcompta/trunk/html/js/gestion.js  2012-05-28 00:44:49 UTC (rev 4846)
@@ -47,6 +47,69 @@
 
 }
 /**
+ address@hidden remove the concerned operation of an action
+ address@hidden dossier
+ address@hidden p_id id pk action_comment_operation
+*/
+function remove_operation(p_dossier,p_id)
+{
+    queryString="gDossier="+p_dossier+"&a=rmop&id="+p_id;
+    var action=new Ajax.Request (
+                   "show_document.php",
+                   {
+                   method:'get',
+                   parameters:queryString,
+                   onFailure:errorRemoveDoc,
+                   onSuccess:successRemoveOp
+                   }
+
+               );
+
+}
+function successRemoveOp(request,json)
+{
+       try{
+   var answer=request.responseText.evalJSON(true);
+    var action="acop"+answer.ago_id;
+    $(action).innerHTML="";
+    var doc="op"+answer.ago_id;
+    $(doc).style.color="red";
+    $(doc).href="javascript:alert('Commentaire Effacé')";
+    $(doc).style.textDecoration="line-through";
+       }catch(e){alert(e.message);}
+}
+/**
+ address@hidden remove comment of an action
+ address@hidden dossier
+ address@hidden p_id pk action_gestion_comment
+*/
+function remove_comment(p_dossier,p_id)
+{
+    queryString="gDossier="+p_dossier+"&a=rmcomment&id="+p_id;
+    var action=new Ajax.Request (
+                   "show_document.php",
+                   {
+                   method:'get',
+                   parameters:queryString,
+                   onFailure:errorRemoveDoc,
+                   onSuccess:successRemoveComment
+                   }
+
+               );
+
+}
+function successRemoveComment(request,json)
+{
+   var answer=request.responseText.evalJSON(true);
+    var action="accom"+answer.agc_id;
+    $(action).innerHTML="";
+    var doc="com"+answer.agc_id;
+    $(doc).style.color="red";
+    $(doc).href="javascript:alert('Commentaire Effacé')";
+    $(doc).style.textDecoration="line-through";
+
+}
+/**
  address@hidden error if a document if removed
  */
 function errorRemoveDoc()

Modified: phpcompta/trunk/html/show_document.php
===================================================================
--- phpcompta/trunk/html/show_document.php      2012-05-27 22:57:08 UTC (rev 
4845)
+++ phpcompta/trunk/html/show_document.php      2012-05-28 00:44:49 UTC (rev 
4846)
@@ -58,3 +58,27 @@
         print $json;
     }
 }
+/* remove the operation */
+if ( $action == 'rmop' )
+{
+    if ($User->check_action(RMDOC)==1)
+    {
+               $cn->exec_sql("delete from action_gestion_operation where 
ago_id=$1",
+                               array($_REQUEST['id']));
+        $json=sprintf('{"ago_id":"%s"}',$_REQUEST['id']);
+        header("Content-type: text/html; charset: utf8",true);
+        print $json;
+    }
+}
+/* remove the comment*/
+if ( $action == 'rmcomment' )
+{
+    if ($User->check_action(RMDOC)==1)
+    {
+               $cn->exec_sql("delete from action_gestion_comment where 
agc_id=$1",
+                               array($_REQUEST['id']));
+        $json=sprintf('{"agc_id":"%s"}',$_REQUEST['id']);
+        header("Content-type: text/html; charset: utf8",true);
+        print $json;
+    }
+}

Modified: phpcompta/trunk/include/action.common.inc.php
===================================================================
--- phpcompta/trunk/include/action.common.inc.php       2012-05-27 22:57:08 UTC 
(rev 4845)
+++ phpcompta/trunk/include/action.common.inc.php       2012-05-28 00:44:49 UTC 
(rev 4846)
@@ -292,10 +292,10 @@
                                     "p_name as label ".
                                     " from profile order by 2");
 $ag_dest=new ISelect();
-$ag_dest->name="ag_dest";
+$ag_dest->name="ag_dest_query";
 $aAg_dest[]=array('value'=>0,'label'=>'Public');
 $ag_dest->value=$aAg_dest;
-$ag_dest->selected=(isset($_GET["ag_dest"]))?$_GET["ag_dest"]:0;
+$ag_dest->selected=(isset($_GET["ag_dest_query"]))?$_GET["ag_dest_query"]:0;
 $str_ag_dest=$ag_dest->input();
 
   ?>
@@ -418,12 +418,12 @@
                  $date_end=$_GET['date_end'];
                  $query.=" and ag_timestamp <= 
to_date('$date_end','DD.MM.YYYY')";
          }
-         if ( isset($_GET['ag_dest']))
+         if ( isset($_GET['ag_dest_query']))
          {
-                 if ( $_GET['ag_dest']==0)
+                 if ( $_GET['ag_dest_query']==0)
                        $query .= "and ag_dest is null ";
                  else
-                       $query.= " and ag_dest = ".sql_string($_GET['ag_dest']);
+                       $query.= " and ag_dest = 
".sql_string($_GET['ag_dest_query']);
          }
          $r=$act->myList($p_base,"",$query.$str);
          echo $r;

Modified: phpcompta/trunk/include/action.inc.php
===================================================================
--- phpcompta/trunk/include/action.inc.php      2012-05-27 22:57:08 UTC (rev 
4845)
+++ phpcompta/trunk/include/action.inc.php      2012-05-28 00:44:49 UTC (rev 
4846)
@@ -23,7 +23,7 @@
  */
 require_once('class_ipopup.php');
 global $g_user;
-$retour=HtmlInput::button_anchor(_('Retour 
liste'),HtmlInput::get_to_string(array("ac","gDossier","qcode","ag_dest","query","tdoc","date_start","date_end","see_all","all_action")).'&my_action');
+$retour=HtmlInput::button_anchor(_('Retour 
liste'),HtmlInput::request_to_string(array("ac","gDossier","qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action")).'&my_action');
 //-----------------------------------------------------
 // Follow_Up
 //-----------------------------------------------------

Modified: phpcompta/trunk/include/class_follow_up.php
===================================================================
--- phpcompta/trunk/include/class_follow_up.php 2012-05-27 22:57:08 UTC (rev 
4845)
+++ phpcompta/trunk/include/class_follow_up.php 2012-05-28 00:44:49 UTC (rev 
4846)
@@ -161,6 +161,10 @@
                                 FROM action_gestion_comment where ag_id=$1 
order by agc_id;",
                                array($this->ag_id)
                                );
+
+               // List opération liées
+               $operation=$this->db->get_array("select 
ago_id,j.jr_id,j.jr_internal,j.jr_comment from jrn as j join 
action_gestion_operation as ago on (j.jr_id=ago.jr_id)");
+               $iconcerned=new IConcerned('operation');
         // state
         // Retrieve the value
         $a=$this->db->make_array("select s_id,s_value from document_state ");
@@ -488,7 +492,7 @@
         /* add the number of item */
         $Hid=new IHidden();
         $r.=$Hid->input("nb_item",MAX_ARTICLE);
-
+               
$r.=HtmlInput::request_to_hidden(array("qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action"));
         /* get template */
         ob_start();
         require_once 'template/detail-action.php';
@@ -659,6 +663,7 @@
                        $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment) values ($1,$2,$3)"
                                        
,array($this->ag_id,$_SESSION['g_user'],$this->ag_comment));
                }
+               $this->insert_operation();
     }
     /*! myList($p_filter="")
      * \brief Show list of action by default if sorted on date
@@ -671,7 +676,7 @@
     {
         $str_dossier=dossier::get();
         // for the sort
-        
$url=HtmlInput::get_to_string(array("qcode","ag_dest","query","tdoc","date_start","date_end","see_all","all_action")).$str_dossier.'&'.$p_base;
+        
$url=HtmlInput::get_to_string(array("qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","all_action")).$str_dossier.'&'.$p_base;
 
                $table=new Sort_Table();
                $table->add('Date',$url,'order by ag_timestamp asc','order by 
ag_timestamp desc','da','dd');
@@ -749,7 +754,7 @@
         //show the sub_action
         foreach ($a_row as $row )
         {
-            $href='<A class="document" 
HREF="do.php'.HtmlInput::get_to_string(array("gDossier","qcode","ag_dest","query","tdoc","date_start","date_end","see_all","ac","all_action"))."&".$p_base.'&sa=detail&ag_id='.$row['ag_id'].'">';
+            $href='<A class="document" 
HREF="do.php'.HtmlInput::get_to_string(array("gDossier","qcode","ag_dest_query","query","tdoc","date_start","date_end","see_all","ac","all_action"))."&".$p_base.'&sa=detail&ag_id='.$row['ag_id'].'">';
             $i++;
             $tr=($i%2==0)?'even':'odd';
             if ($row['ag_priority'] < 2) $tr='priority1';
@@ -977,6 +982,8 @@
                        $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment) values ($1,$2,$3)"
                                        
,array($this->ag_id,$_SESSION['g_user'],$this->ag_comment));
                }
+               $this->insert_operation();
+               $this->remove_operation();
         return true;
 
     }
@@ -1019,6 +1026,8 @@
         
$this->ag_contact=(isset($p_array['ag_contact']))?$p_array['ag_contact']:"";
         
$this->ag_comment=(isset($p_array['ag_comment']))?$p_array['ag_comment']:"";
         
$this->ag_remind_date=(isset($p_array['ag_remind_date']))?$p_array['ag_remind_date']:null;
+        
$this->operation=(isset($p_array['operation']))?$p_array['operation']:null;
+        $this->op=(isset($p_array['op']))?$p_array['op']:null;
 
     }
     /*!\brief remove the action
@@ -1081,4 +1090,25 @@
                                array($p_array[$i]));
                }
        }
+       function insert_operation()
+       {
+               if ( trim($this->operation)=='') return;
+               $array=explode(",",$this->operation);
+               for ($i=0;$i<count($array);$i++) {
+                       if ( $this->db->get_value("select count(*) from 
action_gestion_operation
+                               where ag_id=$1 and 
jr_id=$2",array($this->ag_id,$array[$i]))==0)
+                       {
+                               $this->db->exec_sql("insert into 
action_gestion_operation (ag_id,jr_id) values ($1,$2)",
+                                               array($this->ag_id,$array[$i]));
+                       }
+               }
+       }
+       function remove_operation()
+       {
+               if ($this->op==null) return;
+               $op=$this->op;
+               for ($i=0;$i<count($op);$i++){
+                       $this->db->exec_sql("delete from 
action_gestion_operation where ago_id=$1",array($op[$i]));
+               }
+       }
 }

Modified: phpcompta/trunk/include/class_html_input.php
===================================================================
--- phpcompta/trunk/include/class_html_input.php        2012-05-27 22:57:08 UTC 
(rev 4845)
+++ phpcompta/trunk/include/class_html_input.php        2012-05-28 00:44:49 UTC 
(rev 4846)
@@ -230,7 +230,7 @@
      */
     static function detail_op($p_jr_id,$p_mesg)
     {
-        return sprintf('<A class="detail" style="text-decoration:underline" 
HREF="javascript:modifyOperation(%d,%d)">%s</A>',
+        return sprintf('<A class="detail" 
style="text-decoration:underline;display:inline" 
HREF="javascript:modifyOperation(%d,%d)">%s</A>',
                        $p_jr_id,dossier::id(),$p_mesg);
     }
     /**

Modified: phpcompta/trunk/include/template/detail-action.php
===================================================================
--- phpcompta/trunk/include/template/detail-action.php  2012-05-27 22:57:08 UTC 
(rev 4845)
+++ phpcompta/trunk/include/template/detail-action.php  2012-05-28 00:44:49 UTC 
(rev 4846)
@@ -6,10 +6,10 @@
     <?echo $retour;
     ?>
   </div>
-<div style="float:left;width:50%">
+<div style="float:left;width:32%">
 <em> <strong><?php echo $sp->input();   ?></strong></em>
 
-        <table width="50%">
+        <table >
           <TR>
             <TD>
    <?=_('Date')?>
@@ -74,7 +74,7 @@
  <?echo $str_add_button;?>
 
 </div>
-<div style="float:left;width:50%">
+<div style="float:left;width:32%">
         <table>
           <tr>
             <td>
@@ -136,7 +136,24 @@
         </table>
 
 </div>
+       <div style="float:left;width:32%">
+               <ol>
 
+               <?
+               for ($o=0;$o<count($operation);$o++)
+               {
+                       $rmOperation=sprintf("javascript:if ( 
confirm('"._('Voulez-vous effacer cette opération ')."')==true ) 
{remove_operation('%s','%s');}",
+                                       dossier::id(),
+                                       $operation[$o]['ago_id']);
+                       $js= '<a class="mtitle" 
id="acop'.$operation[$o]['ago_id'].'" href="'.$rmOperation.'">Effacer</a>';
+                       echo '<li 
id="op'.$operation[$o]['ago_id'].'">'.h($operation[$o]['jr_comment'])." 
".HtmlInput::detail_op($operation[$o]['jr_id'],$operation[$o]['jr_internal'])." 
"
+                               .$js.'</li>';
+               }
+
+               ?>
+               </ol>
+               <?=$iconcerned->input()?>
+       </div>
 </fieldset>
 <fieldset>
   <legend>
@@ -166,7 +183,12 @@
     <div style="margin-left:100">
    <?php
 for( $c=0;$c<count($acomment);$c++){
-       echo '<p> n°'.$acomment[$c]['agc_id']." 
".h($acomment[$c]['agc_comment']).'('.h($acomment[$c]['tech_user'])." 
".smaller_date($acomment[$c]['str_agc_date']).')</p>';
+       $rmComment=sprintf("javascript:if ( confirm('"._('Voulez-vous effacer 
ce commentaire ')."')==true ) {remove_comment('%s','%s');}",
+                                       dossier::id(),
+                                       $acomment[$c]['agc_id']);
+                       $js= '<a class="mtitle" 
id="accom'.$acomment[$c]['agc_id'].'" href="'.$rmComment.'">Effacer</a>';
+       echo '<p id="com'.$acomment[$c]['agc_id'].'"> 
n°'.$acomment[$c]['agc_id']." 
".h($acomment[$c]['agc_comment']).'('.h($acomment[$c]['tech_user'])." 
".smaller_date($acomment[$c]['str_agc_date']).')'.
+                       $js.'</p>';
 }
 echo $desc->input();
 $style_enl='style="display:inline"';$style_small='style="display:none"';

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2012-05-27 22:57:08 UTC (rev 4845)
+++ phpcompta/trunk/sql/upgrade.sql     2012-05-28 00:44:49 UTC (rev 4846)
@@ -88,3 +88,20 @@
 
 insert into action_gestion_comment (ag_id,agc_date,agc_comment,tech_user) 
select ag_id,ag_timestamp,ag_comment,ag_owner from action_gestion;
 ALTER TABLE action_gestion drop COLUMN ag_comment;
+
+CREATE TABLE action_gestion_operation
+(
+  ago_id bigserial NOT NULL, -- pk
+  ag_id bigint, -- fk to action_gestion
+  jr_id bigint, -- fk to jrn
+  CONSTRAINT action_comment_operation_pkey PRIMARY KEY (ago_id ),
+  CONSTRAINT action_comment_operation_ag_id_fkey FOREIGN KEY (ag_id)
+      REFERENCES action_gestion (ag_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT action_comment_operation_jr_id_fkey FOREIGN KEY (jr_id)
+      REFERENCES jrn (jr_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE
+);
+COMMENT ON COLUMN action_comment_operation.ago_id IS 'pk';
+COMMENT ON COLUMN action_comment_operation.ag_id IS 'fk to action_gestion';
+COMMENT ON COLUMN action_comment_operation.jr_id IS 'fk to jrn';
\ No newline at end of file



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]