source: branches/2.2.0.1/calendar/js/dhtmlx/samples/03_extensions/php/events_rec.php @ 4001

Revision 4001, 1.4 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1<?php
2        include ('../../../codebase/connector/scheduler_connector.php');
3        include ('../../common/config.php');
4       
5        $res=mysql_connect($server, $user, $pass);
6        mysql_select_db($db_name);
7       
8        function delete_related($action){
9                global $scheduler;
10               
11                $status = $action->get_status();
12                $type =$action->get_value("rec_type");
13                $pid =$action->get_value("event_pid");
14                //when serie changed or deleted we need to remove all linked events
15                if (($status == "deleted" || $status == "updated") && $type!=""){
16                        $scheduler->sql->query("DELETE FROM events_rec WHERE event_pid='".$scheduler->sql->escape($action->get_id())."'");
17                }
18                if ($status == "deleted" && $pid !=0){
19                        $scheduler->sql->query("UPDATE events_rec SET rec_type='none' WHERE event_id='".$scheduler->sql->escape($action->get_id())."'");
20                        $action->success();
21                }
22               
23        }
24        function insert_related($action){
25                $status = $action->get_status();
26                $type =$action->get_value("rec_type");
27               
28                if ($status == "inserted" && $type=="none")
29                        $action->set_status("deleted");
30        }
31       
32        $scheduler = new schedulerConnector($res);
33        //$scheduler->enable_log("log.txt",true);
34        $scheduler->event->attach("beforeProcessing","delete_related");
35        $scheduler->event->attach("afterProcessing","insert_related");
36        $scheduler->render_table("events_rec","event_id","start_date,end_date,text,rec_type,event_pid,event_length");
37?>
Note: See TracBrowser for help on using the repository browser.