16 include_once (
"Class.DbObj.php");
101 create table doctimer ( id serial,
102 timerid int not null,
103 level int not null default 0,
108 attachdate timestamp,
109 referencedate timestamp,
118 include_once (
"Class.QueryDb.php");
121 $q =
new QueryDb($this->dbaccess, $this->dbtable);
122 $q->addQuery(
"docid=$docid");
123 $q->addQuery(
"tododate is not null");
124 $q->addQuery(
"timerid=$timerid");
127 if (
$c > 0)
return _(
"timer already set");
140 $originid = intval($originid);
142 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
143 if ($originid == 0)
$err.= _(
"cannot detach : origin id is not set");
145 $q =
new QueryDb($this->dbaccess, $this->dbtable);
146 $q->addQuery(
"docid=$docid");
147 $q->addQuery(
"tododate is not null");
148 $q->addQuery(
"originid=$originid");
151 $err = $this->
exec_query(
"delete from doctimer where docid=$docid and originid=$originid and tododate is not null");
165 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
167 $q =
new QueryDb($this->dbaccess, $this->dbtable);
168 $q->addQuery(
"docid=$docid");
169 $q->addQuery(
"tododate is not null");
172 $err = $this->
exec_query(
"delete from doctimer where docid=$docid and tododate is not null");
187 if (
$docid == 0)
$err = _(
"cannot detach : document id is not set");
188 if (
$timerid == 0)
$err = _(
"cannot detach : timer id is not set");
189 if (
$err ==
"")
$err = $this->
exec_query(
"delete from doctimer where docid=$docid and tododate is not null and timerid=$timerid");
197 $q =
new QueryDb($this->dbaccess,
"DocTimer");
198 $q->addQuery(
"tododate is not null");
199 $q->addQuery(
"tododate < now()");
200 $timerhourlimit =
getParam(
"FDL_TIMERHOURLIMIT", 2);
201 if ((
int)$timerhourlimit <= 0) {
204 $q->addQuery(sprintf(
"tododate > now() - interval '%d hour'", $timerhourlimit));
205 $l =
$q->Query(0, 0,
"TABLE");
206 if (
$q->nb > 0)
return $l;
210 function executeTimerNow()
212 $timer = new_doc($this->dbaccess, $this->timerid);
216 if (!$timer->isAlive())
return sprintf(_(
"cannot execute timer : timer %s is not found") ,
$this->timerid);
218 $err = $timer->executeLevel($this->level, $this->
docid, $msg, $gonextlevel);
220 $yetalivetimer =
new DocTimer($this->dbaccess, $this->
id);
221 if ($yetalivetimer->isAffected()) {
222 $this->donedate = $timer->getTimeDate();
223 $this->tododate =
"";
224 $this->result = $msg;
228 $acts = $timer->getPrevisions($this->referencedate ? $this->referencedate : $this->attachdate,
false, $this->level, 1);
229 if (count($acts) == 1) {
230 $act = current($acts);
231 if ($act[
"execdate"]) {
232 $this->donedate =
'';
234 $this->tododate = $act[
"execdate"];
235 $this->actions = serialize($act[
"actions"]);
exec_query($sql, $lvl=0, $prepare=false)
Add($nopost=false, $nopre=false)
unattachFromOrigin($docid, $originid, &$c=0)
modify($nopost=false, $sfields="", $nopre=false)
unattachDocument($docid, $timerid)
getParam($name, $def="")
must be in core or global type
if($file) if($subject==""&&$file) if($subject=="") $err