function genSD($projectID) { $file = genPDF($projectID, true); $info = getProjectInfo($projectID); $xml = "<Operation>\n <Details>"; $xml .= addParam("requesttemplate", "API"); $xml .= addParam("requester", $info["name"]); $xml .= addParam("email", $info["email"]); $xml .= addParam("subject", $info["title"]); $xml .= addParam("description", $info["notes"]); $date = strtotime($info["duedate"]); $datestr = date("j F Y", $date) . ", 23:59:59"; $xml .= addParam("Due Date", $datestr); $xml .= "</Details>\n </Operation>"; $key = getSDkey(); $method = "ADD_REQUEST"; $postvars = array("OPERATION_NAME" => $method, "TECHNICIAN_KEY" => $key, "INPUT_DATA" => $xml); $url = getSDBaseURL() . "sdpapi/request/"; $res = postAPI($url, $postvars, null, false); $resp = simplexml_load_string($res); if (isset($resp->response->operation->Details[0]->workorderid)) { $wo = $resp->response->operation->Details[0]->workorderid; $url = getSDBaseURL() . "sdpapi/request/{$wo}/attachment?OPERATION_NAME=ADD_ATTACHMENT&TECHNICIAN_KEY={$key}"; $fields = array("file" => '@' . $file); $headers = array('Content-Type: multipart/form-data'); $res = postAPI($url, $fields, $headers, false, false); $resp = simplexml_load_string($res); if (isset($resp->response->operation->result->status)) { if ($resp->response->operation->result->status == "Success") { //complete } } return array('url' => getSDBaseURL() . "WorkOrder.do?woMode=viewWO&woID={$wo}", 'ID' => $wo); } else { return null; } }
throwError($errors); } $action = $_GET['action']; $project = $_SESSION['project']; switch ($action) { case 'get': getItems(); break; case 'delete': delItem(); break; case 'update': updateProj(); break; case 'pdf': genPDF($project, false); break; case 'servicedesk': SDticket($project); break; default: $errors = array("source" => "main", "error" => "Action not valid, exiting"); throwError($errors); } function getItems() { $project = $_SESSION['project']; $query = "SELECT o.irn, o.image_url, o.accession_no, o.title FROM objectProject op\n\t LEFT JOIN objects o ON (op.object_irn = o.irn AND op.object_holder = o.holder)\n\t WHERE op.project_id = " . sqlSafe($project); $res = readQuery($query); $return = array("objects" => array()); while ($row = $res->fetch_row()) {
function check ($action,$id=null) { if ($action == 'write') { $data['pageTitle'] = 'Write Check'; $finance['acid'] = null; if ($id != null) $finance['acid'] = $this->accounting->getAccountID($id); $finance['accountsExpense'] = $this->accounting->getAccounts(false,'minexp'); $finance['accountsChecking'] = $this->accounting->getAccounts(false,'minck'); if (isset($_POST['amount'])) { $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->form_validation->set_rules('checkNumber', 'Check Number', 'required|callback_checkCheckNum'); $this->form_validation->set_rules('date', 'Check Issue Date', 'required'); $this->form_validation->set_rules('amount', 'Check Amount', 'required'); $this->form_validation->set_rules('payee', 'Payee Account', 'required'); $this->form_validation->set_rules('account', 'Account Billed', 'required'); $this->form_validation->set_rules('account_source', 'Account Paid From', 'required'); if ($this->form_validation->run() == TRUE) { // Extract form data $formData = $_POST; // Lookup payee $payeeData = $this->users->getData($formData['payee']); // Don't save payee's name to DB if same as record if ($payeeData['name'] = $formData['payee-name']) $formData['payee-name'] = null; $check = $this->accounting->addCheck($formData); if ($check != false) { $this->load->plugin('pdf_pi'); $html = '<p><b>Ryan</b> Brodkin</p>'; $html.= '<img src="http://glabstudios.com/images/logos/SplatterTransWhtG_650x505.png" />'; $html.= 'I am a penguin.'; genPDF($html, 'check_'.$check['checkNumber'], false); } redirect('/finance/check_register'); } } $data['content']['body'] = $this->load->view('finance/check_write', $finance, true); $data['content']['side'] = $this->load->view('_sidebar', null, true); $this->load->view('main',$data); } }