Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    //$Id: index.php 3931 2011-09-16 08:17:57Z tiefland $
4
 
5
    /**
6
     * @author Lars Tiefland <tiefland@weban.de>
7
     * @copyright 2008 Webagentur Niewerth
8
     * @package Content-management
9
     * @subpackage Projekttool
10
     * @version $Rev: 3931 $
11
     * @license propietary
12
     * @filesource
13
     *
14
     */
15
 
16
    /**
17
     *
18
     * @author Lars Tiefland <tiefland@weban.de>
19
     * @copyright 2008 Webagentur Niewerth
20
     */
21
 
22
 
23
    require_once  "includes/common.php";
24
 
25
    if ( $projekt_recht )
26
    {
27
 
28
        $GLOBALS["ui"]->assign( "bg_rechts", "#" . $webs["bgcolor_rechts"] );
29
        for ( $i = 1; $i <= 12; $i++ )
30
        {
31
            $mon_opts[] = strftime( "%B", mktime(0, 0, 0, $i, 1, date("Y")) );
32
            $mon_values[] = sprintf( "%02d", $i );
33
        }
34
        for ( $i = 1; $i <= 31; $i++ )
35
        {
36
            $tag_opts[] = sprintf( "%02d", $i );
37
            $tag_values[] = sprintf( "%02d", $i );
38
        }
39
        $GLOBALS["ui"]->assign( "tag_opts", $tag_opts );
40
        $GLOBALS["ui"]->assign( "tag_val", $tag_values );
41
        $GLOBALS["ui"]->assign( "mon_opts", $mon_opts );
42
        $GLOBALS["ui"]->assign( "mon_val", $mon_values );
43
        $GLOBALS["ui"]->assign( "y_opts", array(date("Y"), date("Y", strtotime("1 year"))) );
44
        $GLOBALS["ui"]->assign( "y_val", array(date("Y"), date("Y", strtotime("1 year"))) );
45
        if ( in_array($_POST["action"], array("edit", "new")) )
46
        {
47
            $pl_ids[] = -1;
48
            $pl_names[] = "--- Bitte w&auml;hlen ---";
49
            $p = Login::getLogins();
50
            if ( is_array($p) )
51
            {
52
                foreach ( $p as $projekt_leiter )
53
                {
54
                    $pl_ids[] = $projekt_leiter->pl_id;
55
                    $pl_names[] = $projekt_leiter->pl_nname . ", " . $projekt_leiter->pl_vname;
56
                }
57
            }
58
 
59
            $GLOBALS["ui"]->assign( "projekt_leiter_ids", $pl_ids );
60
            $GLOBALS["ui"]->assign( "projekt_leiter", $pl_names );
61
            $p = Projekt_Ort::getProjektOrte();
62
            $po_ids[] = -1;
63
            $po_names[] = "--- Bitte w&auml;hlen ---";
64
            if ( is_array($p) )
65
            {
66
                foreach ( $p as $projekt_ort )
67
                {
68
                    $po_ids[] = $projekt_ort->po_id;
69
                    $po_names[] = $projekt_ort->po_name;
70
                }
71
            }
72
            $GLOBALS["ui"]->assign( "projekt_ort_ids", $po_ids );
73
            $GLOBALS["ui"]->assign( "projekt_orte", $po_names );
74
            $GLOBALS["ui"]->assign("display", (count($po_ids )>1 && count($pl_ids)>1)?true:false);
75
        }
76
        switch ( $_POST["action"] )
77
        {
78
            case "new":
79
                $GLOBALS["ui"]->assign( "tag_sel_von", date("d") );
80
                $GLOBALS["ui"]->assign( "mon_sel_von", date("m") );
81
                $GLOBALS["ui"]->assign( "y_sel_von", date("Y") );
82
                $GLOBALS["ui"]->assign( "tag_sel_bis", date("d") );
83
                $GLOBALS["ui"]->assign( "mon_sel_bis", date("m") );
84
                $GLOBALS["ui"]->assign( "y_sel_bis", date("Y") );
85
                $GLOBALS["ui"]->assign( "action", "save" );
86
                $GLOBALS["ui"]->display( "projekt_new.tpl" );
87
                break;
88
            case "save":
89
            case "update":
90
                $p = new Projekt( $_POST["p_id"] );
91
                $date_von = implode( "-", array_reverse($_POST["p_von"]) );
92
                $date_bis = implode( "-", array_reverse($_POST["p_bis"]) );
93
                $p->update( $_POST["p_id"], $_POST["p_name"], $date_von, $date_bis, $_POST["p_ort_id"],
94
                    $_POST["p_beschreibung"], $_POST["p_leiter_id"] );
95
                $res = $p->save( $_POST["action"] );
96
                //                if($_POST["action"]=="update")
97
                {
98
                    $projekte = Projekt::getProjekte();
99
                    $GLOBALS["ui"]->assign( "projekte", $projekte );
100
                    $GLOBALS["ui"]->assign("display", (count($projekte ))?true:false);
101
                    $GLOBALS["ui"]->display( "index.tpl" );
102
                }
103
                break;
104
            case "delete":
105
                $p = new Projekt( $_POST["id"] );
106
                $res = $p->save( "delete" );
107
                //if($_POST["action"]=="update")
108
                {
109
                    $projekte = Projekt::getProjekte();
110
                    $GLOBALS["ui"]->assign( "projekte", $projekte );
111
                    $GLOBALS["ui"]->assign("display", (count($projekte ))?true:false);
112
                    $GLOBALS["ui"]->display( "index.tpl" );
113
                }
114
                break;
115
            case "edit":
116
            case "view":
117
                if ( isset($_POST["p_id"]) )
118
                {
119
                    $id = $_POST["p_id"];
120
                }
121
                else
122
                {
123
                    $id = $_POST["id"];
124
                }
125
                $p = new Projekt( $id );
126
                $GLOBALS["ui"]->assign( "projekt", $p );
127
                $erg = getDokumente( $p->p_id );
128
                $dokumente = $erg["dokumente"];
129
                $GLOBALS["ui"]->assign( "dokumente", $dokumente );
130
                $rechte = $erg["rechte"];
131
                $GLOBALS["ui"]->assign( "rechte", $rechte );
132
                $GLOBALS["ui"]->assign( "none", $erg["view"] );
133
                $date_elems_bis = explode( "-", $p->p_bis );
134
                $date_elems_von = explode( "-", $p->p_von );
135
 
136
                $GLOBALS["ui"]->assign( "tag_sel_bis", $date_elems_bis[2] );
137
                $GLOBALS["ui"]->assign( "mon_sel_bis", $date_elems_bis[1] );
138
                $GLOBALS["ui"]->assign( "y_sel_bis", $date_elems_bis[0] );
139
                $GLOBALS["ui"]->assign( "tag_sel_von", $date_elems_von[2] );
140
                $GLOBALS["ui"]->assign( "mon_sel_von", $date_elems_von[1] );
141
                $GLOBALS["ui"]->assign( "y_sel_von", $date_elems_von[0] );
142
                $GLOBALS["ui"]->assign( "id", $p->p_id );
143
                $GLOBALS["ui"]->assign( "view", ($_POST["action"] == "view") ? true : false );
144
                $GLOBALS["ui"]->assign( "action", ($_POST["action"] == "edit") ? "update" : "edit" );
145
 
146
                $GLOBALS["ui"]->display( ($_POST["action"] == "edit") ? "projekt_new.tpl" :
147
                    "projekt_view.tpl" );
148
                break;
149
            default:
150
                $projekte = Projekt::getProjekte();
151
                $GLOBALS["ui"]->assign( "projekte", $projekte );
152
                $GLOBALS["ui"]->assign("display", (count($projekte ))?true:false);
153
                $GLOBALS["ui"]->display( "index.tpl" );
154
                break;
155
        }
156
    }
157
    else
158
    {
159
        die( "Sie haben nicht das Recht dieses Tool zu nuten!" );
160
    }
161
 
162
?>