Author: danydb Date: 2013-09-23 18:25:46 +0200 (Mon, 23 Sep 2013) New Revision: 5413
Added: phpcompta/trunk/include/ajax_tag_add_action.php phpcompta/trunk/include/ajax_tag_detail.php phpcompta/trunk/include/ajax_tag_list.php phpcompta/trunk/include/ajax_tag_remove_action.php phpcompta/trunk/include/template/tag_detail.php phpcompta/trunk/include/template/tag_list.php phpcompta/trunk/include/template/tag_select.php Modified: phpcompta/trunk/include/cfgtags.inc.php phpcompta/trunk/include/class_follow_up.php phpcompta/trunk/include/class_tag.php phpcompta/trunk/include/class_tag_sql.php phpcompta/trunk/include/template/detail-action.php Log: Tag : gestion Tag dans document : ajout, enlever Added: phpcompta/trunk/include/ajax_tag_add_action.php =================================================================== --- phpcompta/trunk/include/ajax_tag_add_action.php (rev 0) +++ phpcompta/trunk/include/ajax_tag_add_action.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,46 @@ +<?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 [email protected] +if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); + +$fl=new Follow_Up($cn); +$fl->ag_id=$_REQUEST['ag_id']; +if ( $g_user->can_write_action($fl->ag_id) == TRUE ) + $fl->tag_add($_REQUEST['t_id']); + +ob_start(); + +$fl->tag_cell(); + +$response= ob_get_clean(); +ob_end_clean(); +$html=escape_xml($response); +header('Content-type: text/xml; charset=UTF-8'); +echo <<<EOF +<?xml version="1.0" encoding="UTF-8"?> +<data> +<ctl></ctl> +<code>$html</code> +</data> +EOF; +exit(); + + +?> Added: phpcompta/trunk/include/ajax_tag_detail.php =================================================================== --- phpcompta/trunk/include/ajax_tag_detail.php (rev 0) +++ phpcompta/trunk/include/ajax_tag_detail.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,38 @@ +<?php +/** + * @brief display a window with the content of a tag + */ +if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); +require_once 'class_tool_uos.php'; +require_once 'class_tag.php'; +ob_start(); +$tag=new Tag($cn); +$tag->data->t_id=$_GET['tag']; +$tag->data->load(); +echo HtmlInput::title_box("Détail du dossier / tag", "tag_div"); + +?> +<form id="tag_frm_detail" method="post"> + <?php + echo dossier::hidden(); + echo HtmlInput::hidden('t_id', $_GET['tag']); + echo HtmlInput::hidden('ac',$_GET['ac']); + $data=$tag->data; + require_once 'template/tag_detail.php'; + echo HtmlInput::submit("save_tag", "Valider"); + ?> +</form> +<?php + $response= ob_get_clean(); + ob_end_clean(); + $html=escape_xml($response); + header('Content-type: text/xml; charset=UTF-8'); + echo <<<EOF +<?xml version="1.0" encoding="UTF-8"?> +<data> +<ctl></ctl> +<code>$html</code> +</data> +EOF; + exit(); + ?> \ No newline at end of file Added: phpcompta/trunk/include/ajax_tag_list.php =================================================================== --- phpcompta/trunk/include/ajax_tag_list.php (rev 0) +++ phpcompta/trunk/include/ajax_tag_list.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,42 @@ +<?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 [email protected] +if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); + +require_once 'class_tag.php'; +ob_start(); +$tag=new Tag($cn); +$tag->select(); + +$response= ob_get_clean(); +ob_end_clean(); +$html=escape_xml($response); +header('Content-type: text/xml; charset=UTF-8'); +echo <<<EOF +<?xml version="1.0" encoding="UTF-8"?> +<data> +<ctl></ctl> +<code>$html</code> +</data> +EOF; +exit(); + + +?> Added: phpcompta/trunk/include/ajax_tag_remove_action.php =================================================================== --- phpcompta/trunk/include/ajax_tag_remove_action.php (rev 0) +++ phpcompta/trunk/include/ajax_tag_remove_action.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,46 @@ +<?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 [email protected] +if ( !defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); + +$fl=new Follow_Up($cn); +$fl->ag_id=$_REQUEST['ag_id']; + +if ( $g_user->can_write_action($fl->ag_id) == TRUE ) $fl->tag_remove($_REQUEST['t_id']); + +ob_start(); + +$fl->tag_cell(); + +$response= ob_get_clean(); +ob_end_clean(); +$html=escape_xml($response); +header('Content-type: text/xml; charset=UTF-8'); +echo <<<EOF +<?xml version="1.0" encoding="UTF-8"?> +<data> +<ctl></ctl> +<code>$html</code> +</data> +EOF; +exit(); + + +?> Modified: phpcompta/trunk/include/cfgtags.inc.php =================================================================== --- phpcompta/trunk/include/cfgtags.inc.php 2013-09-23 16:25:12 UTC (rev 5412) +++ phpcompta/trunk/include/cfgtags.inc.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -24,4 +24,31 @@ * @brief Manage the tags * */ +require_once 'class_tag.php'; +require_once 'class_tool_uos.php'; + +$tag=new Tag($cn); +$uos=new Tool_Uos('tag'); +if ( isset ($_POST['save_tag'])) +{ + try { + $uos->check(); + $tag->save($_POST); + $uos->save(); + } catch (Exception $e) + { + alert("déjà sauvé"); + } +} ?> +<div style="margin-left:10%;width:80%"> + <p class="notice"> + Vous pouvez utiliser ceci comme des tags pour marquer des documents ou + comme des dossiers pour rassembler des documents. Un document peut appartenir + à plusieurs dossiers ou avoir plusieurs tags. + </p> + <?php + $tag->show_list(); + $js=sprintf("onclick=\"show_tag('%s','%s','%s')\"",Dossier::id(),$_REQUEST['ac'],'-1'); + echo HtmlInput::button("tag_add", "Ajout d'un dossier", $js); + ?> \ No newline at end of file Modified: phpcompta/trunk/include/class_follow_up.php =================================================================== --- phpcompta/trunk/include/class_follow_up.php 2013-09-23 16:25:12 UTC (rev 5412) +++ phpcompta/trunk/include/class_follow_up.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -37,6 +37,7 @@ require_once('class_inum.php'); require_once 'class_sort_table.php'; require_once 'class_irelated_action.php'; +require_once 'class_tag.php'; /** * \file @@ -509,6 +510,7 @@ $Hid = new IHidden(); $r.=$Hid->input("nb_item", MAX_ARTICLE); $r.=HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "query", "tdoc", "date_start", "date_end", "hsstate")); + $a_tag=$this->tag_get(); /* get template */ ob_start(); require_once 'template/detail-action.php'; @@ -1409,4 +1411,64 @@ jr_id=$1",array($p_jr_id)); return $array; } + /** + * @brief get the tags of the current objet + * @return an array idx [ag_id,t_id,at_id,t_tag] + */ + function tag_get() + { + if ($this->ag_id==0)return; + $sql='select b.ag_id,b.t_id,b.at_id,a.t_tag' + . ' from ' + .' tags as a join action_tags as b on (a.t_id=b.t_id)' + . ' where ag_id=$1 ' + .' order by a.t_tag'; + $array=$this->db->get_array($sql,array($this->ag_id)); + return $array; + } + /** + * @brief show the tags of the current objet + * normally used by ajax. The same tag cannot be added twice + * + */ + function tag_add($p_t_id) + { + if ($this->ag_id==0)return; + $count=$this->db->get_value('select count(*) from action_tags'. + ' where ag_id=$1 and t_id=$2', + array($this->ag_id,$p_t_id)); + if ( $count > 0 ) return; + $sql=' insert into action_tags (ag_id,t_id) values ($1,$2)'; + $this->db->exec_sql($sql,array($this->ag_id,$p_t_id)); + + } + /** + * @brief remove the tags of the current objet + * normally used by ajax + */ + function tag_remove($p_t_id) + { + if ($this->ag_id==0)return; + $sql=' delete from action_tags where ag_id=$1 and t_id=$2'; + $this->db->exec_sql($sql,array($this->ag_id,$p_t_id)); + } + function tag_cell() + { + $a_tag=$this->tag_get(); + $c=count($a_tag); + for ($e=0;$e<$c;$e++) { + $js_remove=sprintf("onclick=\"action_tag_remove('%s','%s','%s')\"",dossier::id(),$this->ag_id, + $a_tag[$e]['t_id']); + echo '<span style="border:1px solid black">'; + echo $a_tag[$e]['t_tag']; + echo '</span>'; + echo '<span style="background-color:red;text-align:center;border-top:1px solid black; border-right:1px solid black;border-bottom:1px solid black;">'; + echo HtmlInput::anchor("X", "javascript:void(0)", $js_remove).' '; + echo '</span>'; + echo ' '; + } + $js=sprintf("onclick=\"action_tag_select('%s','%s')\"",dossier::id(),$this->ag_id); + echo HtmlInput::button('tag_bt', 'Ajout tag',$js, 'smallbutton'); + + } } Modified: phpcompta/trunk/include/class_tag.php =================================================================== --- phpcompta/trunk/include/class_tag.php 2013-09-23 16:25:12 UTC (rev 5412) +++ phpcompta/trunk/include/class_tag.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -31,8 +31,32 @@ { $ret=$this->data->seek(' order by t_tag'); if ( $this->cn->count($ret) == 0) return ""; - + require_once 'template/tag_list.php'; } + function select() + { + $ret=$this->data->seek(' order by t_tag'); + if ( $this->cn->count($ret) == 0) return "aucun tag trouvé"; + require_once 'template/tag_select.php'; + } + function form_add() + { + $data=$this->data; + require_once 'template/tag_detail.php'; + } + function show_form_add() + { + echo '<h2>'.' Ajout d\'un dossier (ou tag)'.'</h2>'; + + $this->form_add(); + } + function save($p_array) + { + $this->data->t_id=$p_array['t_id']; + $this->data->t_tag=str_ireplace('<script>','<_script_>',$p_array['t_tag']); + $this->data->t_description=str_ireplace('<script>','<_script_>',$p_array['t_description']); + $this->data->save(); + } } ?> Modified: phpcompta/trunk/include/class_tag_sql.php =================================================================== --- phpcompta/trunk/include/class_tag_sql.php 2013-09-23 16:25:12 UTC (rev 5412) +++ phpcompta/trunk/include/class_tag_sql.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -30,7 +30,7 @@ function __construct(& $p_cn, $p_id = -1) { - $this->table = "public.tag"; + $this->table = "public.tags"; $this->primary_key = "t_id"; $this->name = array( Modified: phpcompta/trunk/include/template/detail-action.php =================================================================== --- phpcompta/trunk/include/template/detail-action.php 2013-09-23 16:25:12 UTC (rev 5412) +++ phpcompta/trunk/include/template/detail-action.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -124,8 +124,17 @@ </TD> <td> <?php echo $str_ag_dest;?> + </tr> + <tr> <TD> + Dossier / tags </TD> + + <td id="action_tag_td"> + <?php + $this->tag_cell(); + ?> + </td> </TR> </table> Added: phpcompta/trunk/include/template/tag_detail.php =================================================================== --- phpcompta/trunk/include/template/tag_detail.php (rev 0) +++ phpcompta/trunk/include/template/tag_detail.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,16 @@ +<?php +echo Dossier::hidden(); +echo HtmlInput::hidden('t_id',$data->t_id); +echo HtmlInput::hidden('ac',$_REQUEST['ac']); +$uos=new Tool_Uos('tag'); +echo $uos->hidden(); +$t_tag=new IText('t_tag',$data->t_tag); +$t_description=new ITextarea('t_description',$data->t_description); +$t_description->style=' class="itextarea" style="width:50em;height:5em;vertical-align: top;"'; +?> +<p> + Nom de Dossier (tag) : <?php echo $t_tag->input(); ?> +</p> +<p> +Description (tag) : <?php echo $t_description->input(); ?> +</p> \ No newline at end of file Added: phpcompta/trunk/include/template/tag_list.php =================================================================== --- phpcompta/trunk/include/template/tag_list.php (rev 0) +++ phpcompta/trunk/include/template/tag_list.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,35 @@ +<?php +$max=$this->cn->count($ret); +?> +<table> + <tr> + <th> + Tag + </th> + <th> + Description + </th> + </tr> +<?php +$gDossier=Dossier::id(); +$ac=$_REQUEST['ac']; + for ($i=0;$i<$max;$i++): + $row=Database::fetch_array($ret, $i); +?> + <tr class="<?php echo (($i%2==0)?'even':'odd');?>"> + <td> + <?php + $js=sprintf("show_tag('%s','%s','%s')",$gDossier,$ac,$row['t_id']); + echo HtmlInput::anchor($row['t_tag'], "", "onclick=\"$js\""); + ?> + </td> + <td> + <?php + echo $row['t_description']; + ?> + </td> + </tr> +<?php + endfor; + ?> +</table> \ No newline at end of file Added: phpcompta/trunk/include/template/tag_select.php =================================================================== --- phpcompta/trunk/include/template/tag_select.php (rev 0) +++ phpcompta/trunk/include/template/tag_select.php 2013-09-23 16:25:46 UTC (rev 5413) @@ -0,0 +1,36 @@ +<?php +echo HtmlInput::title_box('Tag', 'tag_div'); +$max=$this->cn->count($ret); +?> +<table> + <tr> + <th> + Tag + </th> + <th> + Description + </th> + </tr> +<?php +$gDossier=Dossier::id(); +if (isNumber($_REQUEST['ag_id']) == 0 ) die ('ERROR : parameters invalid'); + for ($i=0;$i<$max;$i++): + $row=Database::fetch_array($ret, $i); +?> + <tr class="<?php echo (($i%2==0)?'even':'odd');?>"> + <td> + <?php + $js=sprintf("action_tag_add('%s','%s','%s')",$gDossier,$_REQUEST['ag_id'],$row['t_id']); + echo HtmlInput::anchor($row['t_tag'], "", "onclick=\"$js\""); + ?> + </td> + <td> + <?php + echo $row['t_description']; + ?> + </td> + </tr> +<?php + endfor; + ?> +</table> \ No newline at end of file --- PhpCompta est un logiciel de comptabilité libre en ligne (full web) Projet opensource http://www.phpcompta.eu _______________________________________________ Phpcompta est un logiciel libre de comptabilité en ligne (http://www.phpcompta.eu) Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
