18 include_once (
"Class.DbObj.php");
63 create table doctimer ( id serial,
65 level int not null default 0,
79 include_once (
"Class.QueryDb.php");
80 $docid = intval($this->docid);
81 $timerid = intval($this->timerid);
82 $q =
new QueryDb($this->dbaccess, $this->dbtable);
83 $q->addQuery(
"docid=$docid");
84 $q->addQuery(
"tododate is not null");
85 $q->addQuery(
"timerid=$timerid");
88 if (
$c > 0)
return _(
"timer already set");
100 $originid = intval($originid);
102 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
103 if ($originid == 0)
$err.= _(
"cannot detach : origin id is not set");
105 $q =
new QueryDb($this->dbaccess, $this->dbtable);
106 $q->addQuery(
"docid=$docid");
107 $q->addQuery(
"tododate is not null");
108 $q->addQuery(
"originid=$originid");
111 $err = $this->
exec_query(
"delete from doctimer where docid=$docid and originid=$originid and tododate is not null");
125 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
127 $q =
new QueryDb($this->dbaccess, $this->dbtable);
128 $q->addQuery(
"docid=$docid");
129 $q->addQuery(
"tododate is not null");
132 $err = $this->
exec_query(
"delete from doctimer where docid=$docid and tododate is not null");
145 $timerid = intval($timerid);
147 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
148 if ($timerid == 0)
$err = _(
"cannot detach : timer id is not set");
149 if (
$err ==
"")
$err = $this->
exec_query(
"delete from doctimer where docid=$docid and tododate is not null and timerid=$timerid");
157 $q =
new QueryDb($this->dbaccess,
"DocTimer");
158 $q->addQuery(
"tododate is not null");
159 $q->addQuery(
"tododate < now()");
160 $timerhourlimit =
getParam(
"FDL_TIMERHOURLIMIT", 2);
161 $q->addQuery(
"tododate > now() - interval '$timerhourlimit hour'");
162 $l =
$q->Query(0, 0,
"TABLE");
163 if (
$q->nb > 0)
return $l;
169 $timer = new_doc($this->dbaccess, $this->timerid);
170 if (!$timer->isAlive())
return sprintf(_(
"cannot execute timer : timer %s is not found") , $timerid);
172 $err = $timer->executeLevel($this->level, $this->docid, $msg, $gonextlevel);
174 $yetalivetimer =
new DocTimer($this->dbaccess, $this->
id);
175 if ($yetalivetimer->isAffected()) {
176 $this->donedate = $timer->getTimeDate();
177 $this->tododate =
"";
178 $this->result = $msg;
182 $acts = $timer->getPrevisions($this->attachdate,
false, $this->level, 1);
183 if (count($acts) == 1) {
184 $act = current($acts);
185 if ($act[
"execdate"]) {
186 $this->donedate =
'';
188 $this->tododate = $act[
"execdate"];
189 $this->actions = serialize($act[
"actions"]);