altocompta/include/class_todo_list.php
Dany De Bontridder 38972238f8 Merged revisions 2872-2896 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel500

........
  r2874 | danydb | 2010-01-15 15:52:38 +0100 (Fri, 15 Jan 2010) | 3 lines
  
  The extra info are now available for ledger purchase, opportunity to clean
  code
........
  r2875 | danydb | 2010-01-15 19:51:33 +0100 (Fri, 15 Jan 2010) | 2 lines
  
  Fix bug : in rapport, the from doesn't work, the result is always 0
........
  r2876 | danydb | 2010-01-16 17:17:50 +0100 (Sat, 16 Jan 2010) | 1 line
  
  For Comptabilité->ACH and Comptabilité->VEN add shortcut to printing and customer/supplier
........
  r2877 | danydb | 2010-01-16 17:30:56 +0100 (Sat, 16 Jan 2010) | 2 lines
  
  Action : add search by type of documents
........
  r2878 | danydb | 2010-01-17 00:31:03 +0100 (Sun, 17 Jan 2010) | 1 line
  
  Fix bug : cannot choose a tva rate
........
  r2879 | danydb | 2010-01-20 22:37:11 +0100 (Wed, 20 Jan 2010) | 6 lines
  
  Action
  ======
  add a button for adding a card there is no filter on the category
  You can add whatever you want
........
  r2880 | danydb | 2010-01-21 16:10:57 +0100 (Thu, 21 Jan 2010) | 1 line
  
  Correct stylesheet : todo list 
........
  r2882 | danydb | 2010-01-21 16:15:54 +0100 (Thu, 21 Jan 2010) | 1 line
  
  Change Suivi Courrier by Suivi
........
  r2883 | danydb | 2010-01-21 16:38:42 +0100 (Thu, 21 Jan 2010) | 1 line
  
  Style color is now a copy of style light
........
  r2884 | danydb | 2010-01-22 12:54:57 +0100 (Fri, 22 Jan 2010) | 3 lines
  
  Bug: cannot see all the follow up in the list
  Improve : border orange for today
........
  r2885 | danydb | 2010-01-22 13:03:36 +0100 (Fri, 22 Jan 2010) | 2 lines
  
  Remove debug info
........
  r2886 | danydb | 2010-01-22 13:12:54 +0100 (Fri, 22 Jan 2010) | 2 lines
  
  Fix bug : date order in todo list
........
  r2887 | danydb | 2010-01-22 13:14:02 +0100 (Fri, 22 Jan 2010) | 2 lines
  
  Improve fix order for todo list
........
  r2888 | danydb | 2010-01-22 15:30:39 +0100 (Fri, 22 Jan 2010) | 8 lines
  
  Fix bug : 
  * show all actions (no filter anymore)
  * Show interne if in an action there is no card
  Improve : 
  * todo list highlight today
  * calendar highlight today
            
........
  r2889 | danydb | 2010-01-22 23:21:39 +0100 (Fri, 22 Jan 2010) | 1 line
  
  Improve action : description can be enlarged for big note
........
  r2890 | danydb | 2010-01-22 23:39:28 +0100 (Fri, 22 Jan 2010) | 2 lines
  
  Improve : enlarge if description > 300 char
........
  r2891 | danydb | 2010-01-22 23:40:20 +0100 (Fri, 22 Jan 2010) | 2 lines
  
  improve : big desc if > 300 char
........
  r2892 | danydb | 2010-01-22 23:40:49 +0100 (Fri, 22 Jan 2010) | 1 line
  
  Improve Item forecast = 50
........
  r2893 | danydb | 2010-01-23 17:12:33 +0100 (Sat, 23 Jan 2010) | 1 line
  
  Update Documentation
........
  r2894 | danydb | 2010-01-23 19:36:53 +0100 (Sat, 23 Jan 2010) | 1 line
  
  Fix Bug : unknow tag for document : vent_art_tva_code
........
  r2895 | danydb | 2010-01-23 22:19:29 +0100 (Sat, 23 Jan 2010) | 1 line
  
  Add Example of invoice
........
  r2896 | danydb | 2010-01-23 22:20:22 +0100 (Sat, 23 Jan 2010) | 1 line
  
  Update logo
........
2010-01-23 21:49:50 +00:00

199 lines
5.5 KiB
PHP

<?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 ddebontridder@yahoo.fr
/*!\file
* \brief the todo list is managed by this class
*/
require_once('function_javascript.php');
/*!\brief
* This class manages the table todo_list
*
*
* Data Member :
* - $cn database connx
* - $variable
* - id (todo_list.tl_id)
* - date (todo_list.tl_Date)
* - title (todo_list.title)
* - desc (todo_list.tl_desc)
* - owner (todo_list.use_id)
*
*/
class Todo_List
{
private static $variable=array(
"id"=>"tl_id",
"date"=>"tl_date",
"title"=>"tl_title",
"desc"=>"tl_desc",
"owner"=>"use_login");
private $cn;
private $tl_id,$tl_date,$tl_title,$use_login;
function __construct ($p_init) {
$this->cn=$p_init;
$this->tl_id=0;
$this->tl_desc="";
$this->use_login=$_SESSION['g_user'];
}
public function get_parameter($p_string) {
if ( array_key_exists($p_string,self::$variable) ) {
$idx=self::$variable[$p_string];
return $this->$idx;
}
else
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
}
public function check($p_idx,&$p_value) {
if ( strcmp ($p_idx, 'tl_id') == 0 ) { if ( strlen($p_value) > 6 || isNumber ($p_value) == false) return false;}
if ( strcmp ($p_idx, 'tl_date') == 0 ) { if ( strlen(trim($p_value)) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false;}
if ( strcmp ($p_idx, 'tl_title') == 0 ) {
$p_value=substr($p_value,0,120) ;
return true;
}
if ( strcmp ($p_idx, 'tl_desc') == 0 ) { $p_value=substr($p_value,0,400) ; return true;}
return true;
}
public function set_parameter($p_string,$p_value) {
if ( array_key_exists($p_string,self::$variable) ) {
$idx=self::$variable[$p_string];
if ($this->check($idx,$p_value) == true ) $this->$idx=$p_value;
}
else
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
}
public function get_info() { return var_export(self::$variable,true); }
public function verify() {
if ( isDate($this->tl_date) == false ) {
alert('Date est invalide');
return 1;
}
return 0;
}
public function save() {
if ( $this->get_parameter("id") == 0 )
$this->insert();
else
$this->update();
}
public function insert() {
if ( $this->verify() != 0 ) return;
$sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login) ".
" values (to_date($1,'DD.MM.YYYY'),$2,$3,$4) returning tl_id";
$res=$this->cn->exec_sql(
$sql,
array($this->tl_date,
$this->tl_title,
$this->tl_desc,
$this->use_login)
);
$this->tl_id=Database::fetch_result($res,0,0);
}
public function update() {
if ( $this->verify() != 0 ) return;
$sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3 ".
" where tl_id = $4";
$res=$this->cn->exec_sql(
$sql,
array($this->tl_title,
$this->tl_date,
$this->tl_desc,
$this->tl_id)
);
}
/*!\brief load all the task
*\return an array of the existing tasks of the current user
*/
public function load_all() {
$sql="select tl_id, tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date
from todo_list where use_login=$1".
" order by tl_date::date asc";
$res=$this->cn->exec_sql(
$sql,
array($this->use_login));
$array=Database::fetch_all($res);
return $array;
}
public function load() {
$sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date
from todo_list where tl_id=$1";
$res=$this->cn->exec_sql(
$sql,
array($this->tl_id)
);
if ( Database::num_row($res) == 0 ) return;
$row=Database::fetch_array($res,0);
foreach ($row as $idx=>$value) { $this->$idx=$value; }
}
public function delete() {
$sql="delete from todo_list where tl_id=$1";
$res=$this->cn->exec_sql($sql,array($this->tl_id));
}
/**
*@brief transform into xml
*/
public function toXML() {
$id='<tl_id>'.$this->tl_id.'</tl_id>';
$title='<tl_title>'.escape_xml($this->tl_title).'</tl_title>';
$desc='<tl_desc>'.escape_xml($this->tl_desc).'</tl_desc>';
$date='<tl_date>'.$this->tl_date.'</tl_date>';
$ret='<data>'.$id.$title.$desc.$date.'</data>';
return $ret;
}
/*!\brief static testing function
*/
static function test_me() {
$cn=new Database(dossier::id());
$r=new Todo_List($cn);
$r->set_parameter('title','test');
$r->use_login='phpcompta';
$r->set_parameter('date','02.03.2008');
$r->save();
$r->set_parameter('id',3);
$r->load();
print_r($r);
$r->set_parameter('title','Test UPDATE');
$r->save();
print_r($r);
$r->set_parameter('id',1);
$r->delete();
}
}