View difference between Paste ID: RmAZXyvK and B2jMeu2u
SHOW: | | - or go back to the newest paste.
1
<?php
2
function progressdone($type)
3
{
4
    
5
    if (isset($_POST["comment"])) {
6
        
7
        $draft     = "";
8
        $emails    = array();
9
        $report_to = array();
10
        foreach ($this->M_user->getLists() as $k => $r) {
11
            $emails[$r->emp_id]    = $r->email;
12
            $user_name[$r->emp_id] = $r->emp_name;
13
            $report_to[$r->emp_id] = $r->report_to;
14
        }
15
        
16
        $status_order = array(
17
            "" => ""
18
        );
19
        foreach ($this->M_param->getStatusOrder() as $k => $r)
20
            $status_order[$r->STATUS_ORDER_ID] = $r->STATUS_ORDER_NAME;
21
        $cust = array(
22
            "" => ""
23
        );
24
        foreach ($this->M_param->getCustomer() as $k => $r)
25
            $cust[$r->cust_id] = $r->cust_name . " [ " . $r->cust_code . " ]";
26
        
27
        $bu = array(
28
            "" => ""
29
        );
30
        foreach ($this->M_param->getBUList() as $k => $r)
31
            $bu[$r->BU_ID] = $r->BU_NAME;
32
        
33
        $vendor = array(
34
            "" => ""
35
        );
36
        foreach ($this->M_param->getVendor() as $k => $r)
37
            $vendor[$r->vendor_id] = $r->vendor_name;
38
        
39
        // Upload Process
40
        $this->load->library('upload');
41
        $config['upload_path']   = './application/third_party/upload/draft/';
42
        $config['allowed_types'] = '*';
43
        $config['max_size']      = '10000000'; // 10 MB
44
        $config['overwrite']     = TRUE;
45
        
46
        /*
47
        for($i=0; $i<=2; $i++){
48
        if($_FILES["draft_file"]["name"]!="") {
49
        $file_id = md5($_POST["order_id"].date("YmdHis"));
50
        $config['file_name']  = "draft_".$type."_".$file_id;
51
        
52
        $this->upload->initialize($config);
53
        
54
        if ( ! $this->upload->do_upload("draft_file")) {
55
        $error = $this->upload->display_errors();
56
        echo "<script>";
57
        echo "alert('Error: ".$error."');";
58
        echo "document.location.href='".site_url("/lo/progress/".$type."/".$_POST["order_id"])."';";
59
        echo "</script>";
60
        } else {
61
        $data = $this->upload->data();
62
        $draft = $data["file_name"];
63
        
64
        }
65
        }
66
        
67
        }*/
68
        
69
        if (isset($_POST['coba'])) {
70
            
71
            
72
            $coba = $_POST['coba'];
73
            $file = '';
74
            for ($i = 0; $i < count($coba); $i++) {
75
                $file = $coba[$i] . '|' . $file;
76
            }
77
        } else {
78
            $file = '';
79
        }
80
        $this->M_contract->insertHistAppr($_POST["order_id"], $this->session->userdata("d_user_id"), $_POST["rev_reason"], $file, $_POST["status"]);
81
        
82
        // Insert file for hit onthefly
83
        $bitfile = "";
84
        /*$bitfile = date("His");
85
        $myfile = fopen("hit/".$bitfile.".php", "a+") or die("Unable to open file!");
86
        $txt = "<?php\n".
87
        "header(\"location:http://lcm.telkomsigma.co.id/index.php/lo/progress/".$type."/".$_POST["order_id"]."\");\n".
88
        "?>\n";
89
        fwrite($myfile, $txt);
90
        fclose($myfile);*/
91
        
92
        switch ($type) {
93
            case "sales":
94
                $this->M_lo->setLOSalesStatus($_POST["order_id"], $_POST["status"]);
95
                $lo = $this->M_lo->getLOSales("order_id='" . $_POST["order_id"] . "'");
96
                break;
97
            case "purc":
98
                $this->M_lo->setLOVendorStatus($_POST["order_id"], $_POST["status"]);
99
                $lo = $this->M_lo->getLOVendor("order_id='" . $_POST["order_id"] . "'");
100
                break;
101
            case "part":
102
                $this->M_lo->setLOPartnerStatus($_POST["order_id"], $_POST["status"]);
103
                $lo = $this->M_lo->getLOPartner("order_id='" . $_POST["order_id"] . "'");
104
                break;
105
            case "mou":
106
                $this->M_lo->setLOMouStatus($_POST["order_id"], $_POST["status"]);
107
                $lo = $this->M_lo->getLOMou("order_id='" . $_POST["order_id"] . "'");
108
                break;
109
            case "nda":
110
                $this->M_lo->setLONdaStatus($_POST["order_id"], $_POST["status"]);
111
                $lo = $this->M_lo->getLONda("order_id='" . $_POST["order_id"] . "'");
112
                break;
113
        }
114
        
115
        
116
        switch ($type) {
117
            case "sales":
118
                $this->M_profiling->writelog("LO:Sales:Progress", "Updated:" . $_POST["order_id"] . ":" . substr(trim($_POST["rev_reason"]), 0, 10), $this->session->userdata("d_user_id"));
119
                break;
120
            case "purc":
121
                $this->M_profiling->writelog("LO:Purchasing:Progress", "Updated:" . $_POST["order_id"] . ":" . substr(trim($_POST["rev_reason"]), 0, 10), $this->session->userdata("d_user_id"));
122
                break;
123
            case "part":
124
                $this->M_profiling->writelog("LO:Partnership:Progress", "Updated:" . $_POST["order_id"] . ":" . substr(trim($_POST["rev_reason"]), 0, 10), $this->session->userdata("d_user_id"));
125
                break;
126
            case "mou":
127
                $this->M_profiling->writelog("LO:MoU:Progress", "Updated:" . $_POST["order_id"] . ":" . substr(trim($_POST["rev_reason"]), 0, 10), $this->session->userdata("d_user_id"));
128
                break;
129
            case "nda":
130
                $this->M_profiling->writelog("LO:NDA:Progress", "Updated:" . $_POST["order_id"] . ":" . substr(trim($_POST["rev_reason"]), 0, 10), $this->session->userdata("d_user_id"));
131
                break;
132
        }
133
        
134
        // Email notifikasi
135
        //$to = $emails[$_POST["requester"]].(($_POST["legal_officer"]!="")?",".$emails[$_POST["legal_officer"]]:"");
136
        //$cc = $emails[ $report_to[$_POST["requester"]] ].",cicilia.putri@sigma.co.id";
137
        $cc = "fiki.robby@sigma.co.id";
138
        switch ($type) {
139
            case "sales":
140
                $to      = $emails[$_POST["requester"]] . (($_POST["legal_officer"] != "") ? "," . $emails[$_POST["legal_officer"]] : "");
141
                $subject = "[Legal] Progress Status Legal Order Sales " . $_POST["order_id"];
142
                $message = "Dear Legal Officer and Account Manager, <br><br>" . "For Legal Order Sales LO number <b>" . $_POST["order_id"] . "</b> there is a progress that needs to be followed up as follows: <br>" . "<table>" . "<tr><td style='background:#DADADA; width:150px'>No. LO </td><td style='width:650px'><b><a href='lcm.telin.sg/legal/hit/" . $bitfile . ".php'>" . $_POST["order_id"] . "</a></b></td></tr>" . "<tr><td style='background:#DADADA'>No. IWO/Opportunity</td><td><b>" . $lo[0]->iwo_no . "</b></td></tr>" . "<tr><td style='background:#DADADA'>Project Name</td><td>" . $lo[0]->project_name . "</td></tr>" . "<tr><td style='background:#DADADA'>Customer    </td><td>" . $cust[$lo[0]->cust_id] . "</td></tr>" . "<tr><td style='background:#DADADA'>Last Response</td><td>" . $_POST["rev_reason"] . "<br><span style='font-size:10px;font-family:Arial'>by: " . $user_name[$this->session->userdata("d_user_id")] . "</span></td></tr>" . "<tr><td style='background:#DADADA'>Status</td><td>" . $status_order[$_POST["status"]] . "</td></tr>" . "</table><br>" . "Please login <a href='lcm.telin.sg/legal'>Legal Compliance Management</a> for more information." . "<br><br>Thank you.";
143
                
144
                // =====================================================================================================
145
                // $message = "";
146
                // =====================================================================================================
147
                
148
                break;
149
            case "purc":
150
                $to      = $emails[$_POST["requester"]] . (($_POST["legal_officer"] != "") ? "," . $emails[$_POST["legal_officer"]] : "");
151
                $subject = "[Legal] Progress Status Legal Order Purchasing " . $_POST["order_id"];
152
                $message = "Dear. Requester and Legal Officer, <br><br>" . "For Legal Order Sales LO number <b>" . $_POST["order_id"] . "</b> there is a progress that needs to be followed up as follows: <br>" . "<table>" . "<tr><td style='background:#DADADA; width:150px'>No. LO </td><td style='width:650px'><b><a href='lcm.telin.sg/legal/hit/" . $bitfile . ".php'>" . $_POST["order_id"] . "</a></b></td></tr>" . "<tr><td style='background:#DADADA'>No. PO     </td><td><b>" . $lo[0]->po_no . "</b></td></tr>" . "<tr><td style='background:#DADADA'>Project Name</td><td>" . $lo[0]->project_name . "</td></tr>" . "<tr><td style='background:#DADADA'>Mitra   </td><td>" . $vendor[$lo[0]->vendor_id] . "</td></tr>" . "<tr><td style='background:#DADADA'>Last Response</td><td>" . $_POST["rev_reason"] . "<br><span style='font-size:10px;font-family:Arial'>by: " . $user_name[$this->session->userdata("d_user_id")] . "</span></td></tr>" . "<tr><td style='background:#DADADA'>Status</td><td>" . $status_order[$_POST["status"]] . "</td></tr>" . "</table><br>" . "Silahkan login ke <a href='lcm.telin.sg/legal'>Legal Compliance Management</a> For more information." . "<br><br>Thank you.";
153
                break;
154
            case "part":
155
                $to      = $emails[$_POST["requester"]] . (($_POST["legal_officer"] != "") ? "," . $emails[$_POST["legal_officer"]] : "");
156
                $subject = "[Legal] Progress Status Legal Order Partnership " . $_POST["order_id"];
157
                $message = "Dear. Requester and Legal Officer, <br><br>" . "For Legal Order Sales LO number <b>" . $_POST["order_id"] . "</b> there is a progress that needs to be followed up as follows: <br>" . "<table>" . "<tr><td style='background:#DADADA; width:150px'>No. LO </td><td style='width:650px'><b><a href='lcm.telin.sg/legal/hit/" . $bitfile . ".php'>" . $_POST["order_id"] . "</a></b></td></tr>" . "<tr><td style='background:#DADADA'>Project Name</td><td>" . $lo[0]->project_name . "</td></tr>" . "<tr><td style='background:#DADADA'>Last Response</td><td>" . $_POST["rev_reason"] . "<br><span style='font-size:10px;font-family:Arial'>by: " . $user_name[$this->session->userdata("d_user_id")] . "</span></td></tr>" . "<tr><td style='background:#DADADA'>Status</td><td>" . $status_order[$_POST["status"]] . "</td></tr>" . "</table><br>" . "Please login <a href='lcm.telin.sg/legal'>Legal Compliance Management</a> for more information." . "<br><br>Thank you.";
158
                break;
159
            case "mou":
160
                $to      = $emails[$_POST["requester"]] . (($_POST["legal_officer"] != "") ? "," . $emails[$_POST["legal_officer"]] : "");
161
                $subject = "[Legal] Progress Status Legal Order Mou " . $_POST["order_id"];
162
                $message = "Dear. Requester and Legal Officer, <br><br>" . "For Legal Order Sales LO number <b>" . $_POST["order_id"] . "</b> there is a progress that needs to be followed up as follows: <br>" . "<table>" . "<tr><td style='background:#DADADA; width:150px'>No. LO </td><td style='width:650px'><b><a href='lcm.telin.sg/legal/hit/" . $bitfile . ".php'>" . $_POST["order_id"] . "</a></b></td></tr>" . "<tr><td style='background:#DADADA'>Project Name</td><td>" . $lo[0]->project_name . "</td></tr>" . "<tr><td style='background:#DADADA'>Last Response</td><td>" . $_POST["rev_reason"] . "<br><span style='font-size:10px;font-family:Arial'>by: " . $user_name[$this->session->userdata("d_user_id")] . "</span></td></tr>" . "<tr><td style='background:#DADADA'>Status</td><td>" . $status_order[$_POST["status"]] . "</td></tr>" . "</table><br>" . "Please login <a href='lcm.telin.sg/legal'>Legal Compliance Management</a> for more information." . "<br><br>Thank you.";
163
                break;
164
            case "nda":
165
                $to      = $emails[$_POST["requester"]] . (($_POST["legal_officer"] != "") ? "," . $emails[$_POST["legal_officer"]] : "");
166
                $subject = "[Legal] Progress Status Legal Order NDA " . $_POST["order_id"];
167
                $message = "Dear. Requester and Legal Officer, <br><br>" . "For Legal Order Sales LO number <b>" . $_POST["order_id"] . "</b> there is a progress that needs to be followed up as follows: <br>" . "<table>" . "<tr><td style='background:#DADADA; width:150px'>No. LO </td><td style='width:650px'><b><a href='lcm.telin.sg/legal/hit/" . $bitfile . ".php'>" . $_POST["order_id"] . "</a></b></td></tr>" . "<tr><td style='background:#DADADA'>No. IWO/Opportunity</td><td><b>" . $lo[0]->iwo_no . "</b></td></tr>" . "<tr><td style='background:#DADADA'>Project Name</td><td>" . $lo[0]->project_name . "</td></tr>" . "<tr><td style='background:#DADADA'>Customer    </td><td>" . $cust[$lo[0]->cust_name] . "</td></tr>" . "<tr><td style='background:#DADADA'>Last Response</td><td>" . $_POST["rev_reason"] . "<br><span style='font-size:10px;font-family:Arial'>by: " . $user_name[$this->session->userdata("d_user_id")] . "</span></td></tr>" . "<tr><td style='background:#DADADA'>Status</td><td>" . $status_order[$_POST["status"]] . "</td></tr>" . "</table><br>" . "Please login <a href='lcm.telin.sg/legal'>Legal Compliance Management</a> for more information." . "<br><br>Thank you.";
168
                break;
169
        }
170
        
171
        if ($_POST['status'] == 6) {
172
            $config = array(
173
                'smtp_crypto' => 'tls',
174
                'protocol' => 'smtp',
175
                'smtp_host' => 'smtp.office365.com',
176
                'smtp_port' => '587',
177
                'smtp_user' => 'lcm@telin.sg',
178
                'smtp_pass' => 'PvM1cUHXN$',
179
                'mailtype' => 'html',
180
                'charset' => 'utf-8'
181
            );
182
            $this->email->initialize($config);
183
            $this->email->set_mailtype("html");
184
            $this->email->set_newline("\r\n");
185
            $this->email->to('cicilia308@gmail.com');
186
            $this->email->from('lcm@telin.sg', 'Telin LCM');
187
            $this->email->subject('Registration LCM Apps');
188
            $this->email->message($message);
189
            
190
            if (!$this->email->send()) {
191
                echo $this->email->print_debugger();
192
                // redirect("/pr/user");
193
            } else {
194
                echo $this->email->print_debugger();
195
            }
196
        } else {
197
            
198
        }
199
        
200
        $this->M_param->sendEmail($to, $cc, $subject, $message);
201
        
202
        
203
    }
204
    //progressdone
205
    $cond = "UPPER(order_id) LIKE '%" . strtoupper($_POST["order_id"]) . "%'";
206
    $this->viewLegalOrder($type, $cond);
207
    //$this->$type($cond);
208
    //redirect ($this->viewLegalOrder($type,$cond));
209
    //redirect("/lo/sales/".$type."/".$cond);
210
    // redirect("/lo/progress/".$type."/".$_POST["order_id"]);
211
    
212
}
213-
?>
213+
?>