/** * */ function download() { if ($this->Session->check('Search.document_ids')) { $document_ids = $this->Session->read('Search.document_ids'); $repo = $this->requireRepository(); $doc_pack = $repo['Repository']['documentpack_size']; $docs = array(); foreach ($document_ids as $id) { $docs[] = $this->Document->find('first', array('conditions' => array('Document.id' => $id), 'recursive' => -1)); } // if there are more documents, shuffle them if (count($docs) > $doc_pack) { shuffle($docs); $docs_ids = array_rand($docs, $doc_pack); $docs_ids_array = is_array($docs_ids) ? $docs_ids : array($docs_ids); $docs = array_intersect_key($docs, array_flip($docs_ids_array)); } // cgajardo: constituents to be attached $constituents = $this->ConstituentsKit->find('all', array('conditions' => array('ConstituentsKit.kit_id' => $repo['Repository']['kit_id'], 'ConstituentsKit.constituent_id' != '0'), 'recursive' => 2, 'fields' => array("Constituent.sysname"))); // cgajardo: attach folios that belongs to each document foreach ($docs as &$doc) { $doc['files'] = array(); $doc['files'] = $this->Attachfile->find('all', array('conditions' => array('Attachfile.document_id' => $doc['Document']['id']), 'recursive' => -1, 'fields' => array("Attachfile.id", "Attachfile.filename", "Attachfile.type"))); } $this->set(compact('docs', 'doc_pack', 'constituents')); $this->_clean_session(); } }
function render() { $document = Document::find($_SESSION['document_id']); $this->html = file_get_contents('app/views/render/header.pdf.php'); $this->html .= '<div id="cover"> <img src="public/uploads/' . $document->logo . '"> <h1>' . $document->name . '</h1> <div style="position: fixed; bottom: 50px;"> <h3>LONDRINA - PR</h3> <h3>' . $document->year . '</h3> </div> </div>'; $this->html .= file_get_contents('app/views/render/logos.pdf.php'); $counter = 0; foreach ($this->sections as $section => $subs) { $model = Document::find($_SESSION['document_id'])->{$section}; $counter = floor($counter) + 1; foreach ($subs as $label => $name) { if ($label == 'swot') { $this->render_swot($model); } else { $this->html .= '<h2>' . $counter . " {$name}</h2><p>" . $model->{$label} . "</p>"; $counter += 0.1; } } } $this->html .= '</div></body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($this->html); $dompdf->render(); header('Content-Type: application/pdf'); echo $dompdf->output(); }
function render() { $document = Document::find($_SESSION['document_id']); $html = file_get_contents('app/views/render/header.pdf.php'); $html .= '<div id="cover"> <img src="public/uploads/' . $document->logo . '"> <h1>' . "Plano Diretor de Tecnologia da Informação da Prefeitura Municipal de Guaraci" . '</h1> <h3>LONDRINA - PR</h3> <h3>' . $document->year . '</h3> </div>'; $html .= file_get_contents('app/views/render/logos.pdf.php'); foreach ($this->sections as $section => $subs) { $model = Document::find($_SESSION['document_id'])->{$section}(); $counter = 1; foreach ($subs as $label => $name) { $html .= '<h2>' . $counter . " {$name}</h2><p>" . $model->{$label} . "</p>"; $counter += 0.1; } } $html .= '</div></body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); header('Content-Type: application/pdf'); echo $dompdf->output(); }
public function initialize($context, $parameters = null) { parent::initialize($context); $user = $context->getUser(); $id = $context->getRequest()->getParameter('id'); $lang = $context->getRequest()->getParameter('lang'); $document = Document::find('Image', $id); $type = $document->get('image_type'); $this->setParameter('is_moderator', $user->hasCredential('moderator')); $this->setParameter('was', $type); $this->getParameterHolder()->add($parameters); }
public function getDocView($id) { $document = Document::find($id); $user = Document::find($id)->user(); $organization = User::find($document->user->organization_id)->organization; $type = $document->os_type; $items = Document::find($id)->items; // Если такого документа нет, то вернем пользователю ошибку 404 - Не найдено if (!$document) { App::abort(404); } return View::make('inspector.document_view', array('items' => $items, 'document' => $document, 'organization' => $organization)); }
public function initialize($context, $parameters = null) { parent::initialize($context); $user = $context->getUser(); $id = $context->getRequest()->getParameter('id'); if (!empty($id)) { $lang = $context->getRequest()->getParameter('lang'); $document = Document::find('Article', $id); $collaborative_article = $document->get('article_type') == 1; $this->setParameter('is_moderator', $user->hasCredential('moderator')); $this->setParameter('was_collaborative', $collaborative_article); } $this->getParameterHolder()->add($parameters); }
function change() { $document = Document::find($_SESSION['document_id']); if (!empty($_FILES)) { $basename = basename($_FILES['logo']['name']); $uploaded_name = uniqid(rand(), true) . $basename; move_uploaded_file($_FILES['logo']['tmp_name'], 'public/uploads/' . $uploaded_name); $document->logo = $uploaded_name; } $document->name = $this->params('name'); $document->year = $this->params('year'); $document->save(); $this->flash('result', 'Atualizado com sucesso!'); $this->redirect('/documents/' . $_SESSION['document_id'] . '/options'); }
protected function saveModel($document = false) { if (Input::get('id')) { $document = Document::find(Input::get('id')); } if (!$document) { $document = new Document(); } $document->type = Input::get('type'); $document->title = Input::get('title'); $document->description = Input::get('description'); $document->url = Input::get('url'); $document->meta = Input::get('meta'); $document->save(); return $document; }
public function deadline_update() { $updateId = Input::get('updateId'); $changedDate = Input::get('changedDate'); $formatedDate = date("M, jS Y", strtotime($changedDate)); $document = Document::find($updateId); $document->deadline = $changedDate; if ($document->save()) { $suData = array('success' => true); } echo json_encode($suData); exit; }
/** * Get a list of all documents that meet the provided criteria. * * @param array|null $params Optional. An associative array to filter the * list of all documents uploaded. None are * necessary; all are optional. Use the following * options: * - int|null 'limit' The number of documents to * return. * - string|DateTime|null 'createdBefore' Upper * date limit to filter by. * - string|DateTime|null 'createdAfter' Lower * date limit to filter by. * * @return array An array containing document instances matching the * request. * @throws Box\View\BoxViewException */ public function findDocuments($params = []) { return Document::find($this, $params); }
public function get_view_document($id) { return View::make('tenants.documents.create')->with('document', Document::find($id)); }
public function executeInsertimagetag() { $user = $this->getUser(); $prefered_cultures = $user->getCulturesForDocuments(); $module = $this->getRequestParameter('mod'); $id = $this->getRequestParameter('id'); $associated_docs = Association::findAllWithBestName($id, $prefered_cultures); $associated_images = Document::fetchAdditionalFieldsFor(array_filter($associated_docs, array('c2cTools', 'is_image')), 'Image', array('filename', 'image_type')); $doc = Document::find(c2cTools::module2model($module), $id); if (empty($doc)) { $this->setNotFoundAndRedirect(); } if (c2cTools::is_collaborative_document($doc)) { // for collaborative content, keep only collaborative images $associated_images = array_filter($associated_images, array('c2cTools', 'is_collaborative_document')); } $this->document_id = $id; $this->div = $this->getRequestParameter('div'); $this->associated_images = $associated_images; }
public function postUpdate($id) { $document = Document::find($id); $document->document_date = Input::get('document_date'); $document->actual_date = Input::get('actual_date'); $document->save(); return Redirect::action('DocumentsController@getView', [$document->id]); }
public function assignTask() { $id = Input::get('hide_taskid'); $user_id = Auth::user()->id; $taskDetails = TaskDetails::find($id); $taskDetails->assignee_id = $user_id; $taskDetails->status = "Active"; $task_row = Task::find($taskDetails->task_id); $addToDateReceived = $task_row->maxDuration; $taskd = TaskDetails::find($id); $docs = Document::find($taskd->doc_id); if ($taskd->status == "Done") { Session::put('errorchecklist', 'Accept failed. Task was already completed by another user.'); return Redirect::back(); } else { if ($taskd->status == "Active") { Session::put('errorchecklist', 'Accept failed. Task was already accepted by another user.'); return Redirect::back(); } } // Get date today and the due date; $dateReceived = date('Y-m-d H:i:s'); if ($addToDateReceived == 0) { $dueDate = '9999-01-01 00:00:00'; } else { $dueDate = date('Y-m-d H:i:s', strtotime("{$addToDateReceived} days")); } $taskDetails->dateReceived = $dateReceived; $taskDetails->dueDate = $dueDate; $taskDetails->save(); return Redirect::to("task/{$id}"); }
} if (!$DRY_RUN) { $asso = new Association(); $asso->doSaveWithValues($doc['id'], $image_data['id'], $association_type, $TOPO_MODERATOR_USER_ID); } $stat_associations_required++; } $image_ids[$tag[1]] = $image_data['id']; } else { // no corresponding id, the tag is incorrect and must not be modified. but a warning should be notified $stat_docs_with_invalid_references[] = $doc['id'] . ' (' . $doc['culture'] . ' - ' . $doc['name'] . ') http://' . $SERVER_NAME . '/' . strtolower($table) . 's' . '/' . $doc['id'] . '/' . $doc['culture'] . "\n"; } } // replace image tags $conn = sfDoctrine::Connection(); $db_doc = Document::find($table, $doc['id']); if (!$DRY_RUN) { $conn->beginTransaction(); $history_metadata = new HistoryMetadata(); $history_metadata->setComment('Updated image tags'); $history_metadata->set('is_minor', true); $history_metadata->set('user_id', $TOPO_MODERATOR_USER_ID); $history_metadata->save(); $db_doc->setCulture($doc['culture']); } foreach ($fields as $field) { $tag_data = $tags_for_field[$field]; $text = $doc[$field]; foreach ($tag_data as $tag_idx) { $references_to_modify++; $tag = $tags[$tag_idx];
/** summits: refresh geo associations of summit, 'sub' routes and outings */ public function updateGeoAssociations($id) { $referer = $this->getRequest()->getReferer(); $this->document = Document::find($this->model_class, $id, array('summit_type')); if (!$this->document) { $this->setErrorAndRedirect('Document does not exist', $referer); } $nb_created = gisQuery::createGeoAssociations($id, true, true); c2cTools::log("created {$nb_created} geo associations"); $this->refreshGeoAssociations($id); $this->clearCache('summits', $id, false, 'view'); $this->setNoticeAndRedirect('Geoassociations refreshed', "@document_by_id?module=summits&id={$id}"); }
?> <form action="#" method="POST"> <label for="searchid"><b>ID Number (Including Prefix):</b></label> <input type="text" id="searchid" name="searchid" required/><br/> <button id="search" name="search" class="btn btn-primary" type="button" onclick="searchDoc()">Search</button> </form> <div id="loading" class="alert alert-primary" role="alert" style="display: none"> </div> <?php } else { if ($do == 'search') { $id = substr_replace($_POST['searchid'], '', 0, 1); if (!Document::doesExist($id)) { echo 'No such document with that ID!'; } else { if (!Document::find($id, $_SESSION['user'])) { echo 'You do not have access to this document!'; } else { echo 'true'; } } } } } else { if ($action == 'new') { if ($do == 'none') { ?> <form action="#" method="POST"> <input type="hidden" id="assignees" name="assignees" /> <table> <tr>
/** * filter edits which must require additional parameters (link for instance : outing with route or with site) * overrides the one in parent class. */ protected function filterAdditionalParameters() { if (!$this->getRequestParameter('document_id') && !$this->getRequestParameter('link')) { $this->setErrorAndRedirect('You cannot create an outing without linking it to an existing route or site', '@default_index?module=outings'); } $id = $this->getRequestParameter('link', 0) + $this->getRequestParameter('document_id', 0); // linked_doc already retrieved in populateCustomFields() except when creating a new outing if (isset($this->linked_doc)) { $linked_doc = $this->linked_doc; } else { // route (most of the time) or site $linked_doc = Document::find('Route', $id, array('id', 'module')); if (!$linked_doc) { $linked_doc = Document::find('Site', $id, array('id', 'module')); } } if ($linked_doc && $linked_doc->get('module') == 'routes') { if ($this->document) { $linked_doc->set('name', $this->document->get('name')); // contains highest summit too } } if (!$linked_doc) { $this->setErrorAndRedirect('You cannot create an outing without linking it to an existing route or site', '@default_index?module=outings'); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $vehicle = Vehicle::find($id); // LOGS $oldVehiclesStatus = $vehicle->vehicles_status; $newVehiclesStatus = Input::get('vehicles_status'); $oldvehicleColor = $vehicle->color->id; $newVehicleColor = Input::get('vehicles_color'); $oldVehicleUseType = $vehicle->vehicles_use_type; $newVehicleUseType = Input::get('vehicles_use_type'); $vehicles_class = Input::get('vehicles_class'); $oldVehiclesRegistrationNo = $vehicle->registration->registrations_no; $newVehiclesRegistrationNo = Input::get('registrations_no'); $oldOdometer = $vehicle->vehicles_odometer; $newOdometer = Input::get('vehicles_odometer'); // IF VEHICLE STATUS IS CHANGED, ADD LOG if ($oldVehiclesStatus != $newVehiclesStatus) { LogVehicleStatus::create(['log_vehicle_status_vehicle_id' => $id, 'log_vehicle_status_vehicle_status_id' => $newVehiclesStatus]); } // IF VEHICLE COLOR IS CHANGED, ADD LOG if ($oldvehicleColor != $newVehicleColor) { LogVehicleColor::create(['log_vehicle_color_vehicle_id' => $id, 'log_vehicle_color_color_id' => $newVehicleColor]); } // IF VEHICLE USE TYPE IS CHANGED, TAKE LOG (ALSO TAKING LOG OF ODOMETER AND INCREMENT SEQUENCE) if ($oldVehicleUseType != $newVehicleUseType) { LogVehicleUseType::create(['log_vehicle_use_type_vehicle_id' => $id, 'log_vehicle_use_type_use_type' => $newVehicleUseType, 'log_vehicle_use_type_registration_no' => $newVehiclesRegistrationNo]); // INCREMENTING SEQUENCE $vehicles_use_type_table_name = VehicleUseType::find($newVehicleUseType)->vehicle_use_types_table_name; $vehicles_sequence_col_name = $vehicles_use_type_table_name . '_sequence'; $currentSequence = DB::table($vehicles_use_type_table_name)->find($vehicles_class)->{$vehicles_sequence_col_name}; $newSequence = $currentSequence + 1; DB::table($vehicles_use_type_table_name)->where('id', $vehicles_class)->update([$vehicles_sequence_col_name => $newSequence]); // TAKING LOG OF ODOMETER $vehicles_odometer = Input::get('vehicles_odometer'); LogVehicleOdometer::create(['log_vehicle_odometer_vehicle_id' => $id, 'log_vehicle_odometer_old_odometer' => $vehicles_odometer, 'log_vehicle_odometer_status' => 2]); } elseif ($oldOdometer != $newOdometer) { LogVehicleOdometer::create(['log_vehicle_odometer_vehicle_id' => $id, 'log_vehicle_odometer_old_odometer' => $newOdometer, 'log_vehicle_odometer_status' => 4]); } // BEGIN UPDATE VEHICLE DATA $vehicle = Input::only(['vehicles_use_type', 'vehicles_class', 'vehicles_color', 'vehicles_status', 'vehicles_odometer']); Vehicle::where('id', $id)->update($vehicle); // END UPDATE VEHICLE DATA // BEGIN OWNERS //OLD OWNERS $old_owners = Vehicle::find($id)->owners->lists('id'); //UPDATED OLD OWNERS $updated_old_owners_index = Input::get('old_owners_index'); $updated_owners_index_arr = array_filter(explode(',', $updated_old_owners_index)); //DELETED OWNERS $deleted_owners = array_diff($old_owners, $updated_owners_index_arr); // DELETE EACH DELETED OWNER FROM DATABASE foreach ($deleted_owners as $deleted_owner_id) { VehicleDriverOwner::where('vehicle_driver_owners_vehicle_id', $id)->where('vehicle_driver_owners_driver_id', $deleted_owner_id)->delete(); } //RETAINED OWNERS $retained_owners = array_intersect($old_owners, $updated_owners_index_arr); // UPDATE RETAINED OWNERS foreach ($retained_owners as $retained_owner) { $retained_owner_info['drivers_fname'] = Input::get('drivers_fname' . $retained_owner); $retained_owner_info['drivers_mname'] = Input::get('drivers_mname' . $retained_owner); $retained_owner_info['drivers_lname'] = Input::get('drivers_lname' . $retained_owner); $retained_owner_info['drivers_nin'] = Input::get('drivers_nin' . $retained_owner); $retained_owner_info['drivers_license_no'] = Input::get('drivers_license_no' . $retained_owner); $retained_owner_info['drivers_street'] = Input::get('drivers_street' . $retained_owner); $retained_owner_info['drivers_city'] = Input::get('drivers_city' . $retained_owner); $retained_owner_info['drivers_po_box'] = Input::get('drivers_po_box' . $retained_owner); $retained_owner_info['drivers_country'] = Input::get('drivers_country' . $retained_owner); $retained_owner_info['drivers_cell1'] = Input::get('drivers_cell1' . $retained_owner); $retained_owner_info['drivers_cell2'] = Input::get('drivers_cell2' . $retained_owner); $retained_owner_info['drivers_email'] = Input::get('drivers_email' . $retained_owner); $retained_owner_info['drivers_driving_status'] = Input::get('drivers_driving_status' . $retained_owner); Driver::find($retained_owner)->update($retained_owner_info); } // END OWNERS //BEGIN AUTHORIZED DRIVERS $old_authorized = Vehicle::find($id)->authorizedDrivers->lists('id'); //UPDATED OLD AUTHORIZED DRIVERS $updated_old_authorized_index = Input::get('old_authorized_index'); $updated_authorized_index_arr = array_filter(explode(',', $updated_old_authorized_index)); //DELETED AUTHORIZED DRIVERS $deleted_authorized = array_diff($old_authorized, $updated_authorized_index_arr); //DELETE EACH DELETED AUTHORIZED DRIVER FROM DATABASE foreach ($deleted_authorized as $deleted_authorized_id) { VehicleDriverAuthorized::where('vehicle_driver_authorized_vehicle_id', $id)->where('vehicle_driver_authorized_driver_id', $deleted_authorized_id)->delete(); } //RETAINED AUTHORIZED DRIVERS $retained_authorized = array_intersect($old_authorized, $updated_authorized_index_arr); // UPDATE RETAINED AUTHORIZED DRIVERS foreach ($retained_authorized as $retained_authorize) { $retained_authorized_info['drivers_fname'] = Input::get('authorized_fname' . $retained_authorize); $retained_authorized_info['drivers_mname'] = Input::get('authorized_mname' . $retained_authorize); $retained_authorized_info['drivers_lname'] = Input::get('authorized_lname' . $retained_authorize); $retained_authorized_info['drivers_nin'] = Input::get('authorized_nin' . $retained_authorize); $retained_authorized_info['drivers_license_no'] = Input::get('authorized_license_no' . $retained_authorize); $retained_authorized_info['drivers_street'] = Input::get('authorized_street' . $retained_authorize); $retained_authorized_info['drivers_city'] = Input::get('authorized_city' . $retained_authorize); $retained_authorized_info['drivers_po_box'] = Input::get('authorized_po_box' . $retained_authorize); $retained_authorized_info['drivers_country'] = Input::get('authorized_country' . $retained_authorize); $retained_authorized_info['drivers_cell1'] = Input::get('authorized_cell1' . $retained_authorize); $retained_authorized_info['drivers_cell2'] = Input::get('authorized_cell2' . $retained_authorize); $retained_authorized_info['drivers_email'] = Input::get('authorized_email' . $retained_authorize); $retained_authorized_info['drivers_driving_status'] = Input::get('authorized_driving_status' . $retained_authorize); Driver::find($retained_authorize)->update($retained_authorized_info); } //END AUTHORIZED DRIVERS // BEGIN NEW OWNERS $owners_index = Input::get('owners_index'); $owners_index_arr = array_filter(explode(',', $owners_index)); // LOOP THROUGH EACH OWNER AND ASSOCIATE WITH DRIVERS foreach ($owners_index_arr as $owners_index_id) { $drivers_license_no = Input::get('drivers_license_no' . $owners_index_id); if (trim($drivers_license_no) != "") { $drivers_status = Driver::where('drivers_license_no', $drivers_license_no)->first(); // IF DRIVER DOESN'T EXISTS, CREATE DRIVER if ($drivers_status == NULL) { $owner_info['drivers_fname'] = Input::get('drivers_fname' . $owners_index_id); $owner_info['drivers_mname'] = Input::get('drivers_mname' . $owners_index_id); $owner_info['drivers_lname'] = Input::get('drivers_lname' . $owners_index_id); $owner_info['drivers_nin'] = Input::get('drivers_nin' . $owners_index_id); $owner_info['drivers_license_no'] = Input::get('drivers_license_no' . $owners_index_id); $owner_info['drivers_street'] = Input::get('drivers_street' . $owners_index_id); $owner_info['drivers_city'] = Input::get('drivers_city' . $owners_index_id); $owner_info['drivers_po_box'] = Input::get('drivers_po_box' . $owners_index_id); $owner_info['drivers_country'] = Input::get('drivers_country' . $owners_index_id); $owner_info['drivers_cell1'] = Input::get('drivers_cell1' . $owners_index_id); $owner_info['drivers_cell2'] = Input::get('drivers_cell2' . $owners_index_id); $owner_info['drivers_email'] = Input::get('drivers_email' . $owners_index_id); $owner_info['drivers_driving_status'] = Input::get('drivers_driving_status' . $owners_index_id); $insert_owner_into_driver_table = Driver::create($owner_info); $owner_ids[] = $insert_owner_into_driver_table->id; } else { $owner_ids[] = Driver::where('drivers_license_no', $drivers_license_no)->first()->id; } } } // LINK VEHICLE WITH NEW OWNERS if (!empty($owner_ids)) { foreach ($owner_ids as $owner_ids_fet) { $owner_ids_fet = (int) $owner_ids_fet; //VehicleDriverOwner::create(['vehicle_driver_owners_vehicle_id' => $id, 'vehicle_driver_owners_driver_id' => $owner_ids_fet]); Vehicle::find($id)->owners()->attach($owner_ids_fet); } } // END NEW OWNERS //BEGIN NEW AUTHORIZED DRIVERS $authorized_index = Input::get('authorized_index'); // IF AUTHORIZED DRIVERS EXIST, ASSOCIATE WITH DRIVERS.(CHECKING USING LICENSE) if ($authorized_index != "") { $authorized_index_arr = explode(',', $authorized_index); foreach ($authorized_index_arr as $authorized_index_id) { $authorized_license_no = Input::get('authorized_license_no' . $authorized_index_id); $authorized_status = Driver::where('drivers_license_no', $authorized_license_no)->first(); //IF DRIVER DOESN'T EXISTS, CREATE DRIVER if ($authorized_status == NULL) { $authorized_info['drivers_fname'] = Input::get('authorized_fname' . $authorized_index_id); $authorized_info['drivers_mname'] = Input::get('authorized_mname' . $authorized_index_id); $authorized_info['drivers_lname'] = Input::get('authorized_lname' . $authorized_index_id); $authorized_info['drivers_nin'] = Input::get('authorized_nin' . $authorized_index_id); $authorized_info['drivers_license_no'] = Input::get('authorized_license_no' . $authorized_index_id); $authorized_info['drivers_street'] = Input::get('authorized_street' . $authorized_index_id); $authorized_info['drivers_city'] = Input::get('authorized_city' . $authorized_index_id); $authorized_info['drivers_po_box'] = Input::get('authorized_po_box' . $authorized_index_id); $authorized_info['drivers_country'] = Input::get('authorized_country' . $authorized_index_id); $authorized_info['drivers_cell1'] = Input::get('authorized_cell1' . $authorized_index_id); $authorized_info['drivers_cell2'] = Input::get('authorized_cell2' . $authorized_index_id); $authorized_info['drivers_email'] = Input::get('authorized_email' . $authorized_index_id); $authorized_info['drivers_driving_status'] = Input::get('authorized_driving_status' . $authorized_index_id); $insert_authorized_into_driver_table = Driver::create($authorized_info); $authorized_ids[] = $insert_authorized_into_driver_table->id; } else { $authorized_ids[] = Driver::where('drivers_license_no', $authorized_license_no)->first()->id; } } // LINK VEHICLE WITH AUTHORIZED DRIVERS foreach ($authorized_ids as $authorized_ids_fet) { $authorized_ids_fet = (int) $authorized_ids_fet; //VehicleDriverAuthorized::create(['vehicle_driver_authorized_vehicle_id' => $id, 'vehicle_driver_authorized_driver_id' => $authorized_ids_fet]); Vehicle::find($id)->authorizedDrivers()->attach($authorized_ids_fet); } } // END NEW AUTHORIZED DRIVERS // BEGIN INSURANCE if (Input::get('insurances_company') != "") { $insurance_arr = Input::only('insurances_company', 'insurances_policy_no', 'insurances_exp_date', 'insurances_agent_fname', 'insurances_agent_lname', 'insurances_agent_cell', 'insurances_agent_city', 'insurances_agent_email'); if (Insurance::where('insurances_vehicle_id', $id)->first()->id) { Insurance::where('insurances_vehicle_id', $id)->update($insurance_arr); } else { //$insurance_arr['insurances_vehicle_id'] = $id; //Insurance::create($insurance_arr); Vehicle::find($id)->insurance()->save($insurance_arr); } } // END INSURANCE // BEGIN LIEN HOLDER if (Input::get('lien_index')) { $lien_arr = Input::only('liens_collateral_id', 'liens_collateral_value', 'liens_bank_name', 'liens_bank_branch', 'liens_bank_street', 'liens_bank_city'); if (Lien::where('liens_vehicle_id', $id)->first()->id) { Lien::where('liens_vehicle_id', $id)->update($lien_arr); } else { //$lien_arr['liens_vehicle_id'] = $id; //Lien::create($lien_arr); Vehicle::find($id)->lien()->save($lien_arr); } } // END LIEN HOLDER // BEGIN OLD FILES $old_documents_index = Vehicle::find($id)->documents->lists('id'); $documents_index = explode(',', Input::get('documents_index')); $deleted_documents = array_diff($old_documents_index, $documents_index); if (!empty($deleted_documents)) { foreach ($deleted_documents as $deleted_document) { Document::find($deleted_document)->delete(); } } // END OLD FILES // BEGIN NEW FILES $files_col = Input::file(); $files_count = count(array_filter($files_col['files'])); // IF FILES EXISTS if ($files_count) { foreach ($files_col['files'] as $files) { $filename_ar = explode('.', $files->getClientOriginalName()); $document_ext = end($filename_ar); $path = public_path() . '/vehicledata/documents'; // GENERATE RANDOM FILE NAME AND ADD EXTENSION $randName = md5(rand() * time()); $document_name = $randName . '.' . $document_ext; // MOVE FILE AND ENTRY INTO DATABASE if ($files->move($path, $document_name)) { //Document::create(['documents_vehicle_id' => $id, 'documents_name' => $document_name]); Vehicle::find($id)->documents()->save(new Document(['documents_name' => $document_name])); } } } // END NEW FILES // BEGIN REGISTRATION if (isset($id) && $id != "") { $registrations_vehicle_id = $id; $registrations_no = Input::get('registrations_no'); $registrations_licence_plate_no = Input::get('registrations_licence_plate_no'); if ($registrations_no != "" && $registrations_licence_plate_no != "" && $registrations_vehicle_id != "") { $vehicles_use_type = Input::get('vehicles_use_type'); $vehicles_class = Input::get('vehicles_class'); if ($vehicles_use_type != "" && $vehicles_class != "") { $vehicles_use_type_table_name = VehicleUseType::find($vehicles_use_type)->vehicle_use_types_table_name; //REGISTRATION FEES $vehicles_class_col_name = $vehicles_use_type_table_name . '_total'; $registrations_fees = DB::table($vehicles_use_type_table_name)->find($vehicles_class)->{$vehicles_class_col_name}; $registration_ar = compact('registrations_vehicle_id', 'registrations_no', 'registrations_licence_plate_no', 'registrations_fees'); Registration::where('registrations_vehicle_id', $id)->update($registration_ar); return Redirect::route('vehicle.print', [$registrations_vehicle_id]); } } } else { echo "Nothing is saved because fields are not filled"; die; } // END REGISTRATION }
function edit() { $this->meeting = Meeting::find($this->params('meeting_id')); $this->organs = Document::find($_SESSION['document_id'])->organs; }
// this is the case when a GPX has been uploaded on the outing. $item->addChild('geom', "{$lon},{$lat}"); $item->addChild('elevation', $ele); } elseif ($associated_routes = Association::findAllAssociatedDocs($id, $fields = array('id', 'lon', 'lat', 'elevation'), 'ro')) { // find highest route $max_ele = 0; foreach ($associated_routes as $route) { if (($ele = $route['elevation']) && $ele > $max_ele && ($lon = $route['lon']) && ($lat = $route['lat'])) { $highest_route = $route; $max_ele = $ele; } } // get route facing and rating if there is just one associated route: // fetch additional fields : if (count($associated_routes) == 1) { $single_route = Document::find('Route', $route['id'], array('global_rating', 'facing', 'engagement_rating', 'equipment_rating', 'toponeige_technical_rating', 'toponeige_exposition_rating', 'labande_ski_rating', 'labande_global_rating', 'ice_rating', 'mixed_rating', 'rock_free_rating', 'rock_required_rating', 'aid_rating', 'hiking_rating', 'snowshoeing_rating')); if ($rating = trim(field_route_ratings_data($single_route, false, false, true))) { $item->addChild('rating', $rating); } if ($facing = $single_route['facing']) { $item->addChild('facing', $facing); } } if ($max_ele > 0) { $item->addChild('geom', "{$lon},{$lat}"); $item->addChild('elevation', $max_ele); } else { // could not find any geolocalized route to link // => we go to the next step : find highest associated summits to these routes $coords = Route::findHighestAssociatedSummitCoords($associated_routes); if ($coords['ele'] > 0) {
public function getRev() { $q = Input::get('term'); $doc = new Document(); $qdoc = new MongoRegex('/' . $q . '/i'); $res = $doc->find(array('title' => $qdoc), array('title')); $result = array(); foreach ($res as $r) { $result[] = array('id' => $r['_id']->__toString(), 'label' => $r['title'], 'value' => $r['_id']->__toString()); } return Response::json($result); }
/** * filter edits which must require additional parameters (link for instance : route with summit) * overrides the one in parent class */ protected function filterAdditionalParameters() { if (!$this->getRequestParameter('summit_id') && !$this->getRequestParameter('link')) { $this->setErrorAndRedirect('You cannot create a route without linking it to an existing summit', '@default_index?module=routes'); } $id = $this->getRequestParameter('link', 0) + $this->getRequestParameter('summit_id', 0); $linked_doc = Document::find('Summit', $id, array('id', 'module')); if (!$linked_doc) { $this->setErrorAndRedirect('You cannot create a route without linking it to an existing summit', '@default_index?module=routes'); } $this->linked_doc = $linked_doc; }
public function update_document_type() { $id = Input::get('id'); $name = Input::get('name'); if ($id == 0) { $document_type = new Document(); } else { $document_type = Document::find($id); } $document_type->name = $name; $document_type->save(); return Redirect::to("/admin/document-type/edit/{$document_type->id}?success=1"); }
/** * Convert img or tag of ticket for notification mails * * @since version 0.85 * * @param $content : html content of input * @param $item : item to store filenames and tags found for each image in $content * * @return htlm content **/ function convertContentForNotification($content, $item) { global $CFG_GLPI, $DB; $html = str_replace(array('&', '&nbsp;'), array('&', ' '), html_entity_decode($content, ENT_QUOTES, "UTF-8")); // If is html content if ($CFG_GLPI["use_rich_text"]) { preg_match_all('/img\\s*alt=[\'|"](([a-z0-9]+|[\\.\\-]?)+)[\'|"]/', $html, $matches, PREG_PATTERN_ORDER); if (isset($matches[1]) && count($matches[1])) { if (count($matches[1])) { foreach ($matches[1] as $image) { //Replace tags by image in textarea $img = "img src='cid:" . Document::getImageTag($image) . "'"; //Replace tag by the image $html = preg_replace("/img alt=['|\"]" . $image . "['|\"].*src=['|\"](.+)['|\"]/", $img, $html); } } } $content = $html; } else { // If is text content $doc = new Document(); $doc_data = array(); preg_match_all('/' . Document::getImageTag('(([a-z0-9]+|[\\.\\-]?)+)') . '/', $content, $matches, PREG_PATTERN_ORDER); if (isset($matches[1]) && count($matches[1])) { $doc_data = $doc->find("tag IN('" . implode("','", array_unique($matches[1])) . "')"); } if (count($doc_data)) { foreach ($doc_data as $image) { // Replace tags by image in textarea $img = "<img src='cid:" . Document::getImageTag($image['tag']) . "'/>"; // Replace tag by the image $content = preg_replace('/' . Document::getImageTag($image['tag']) . '/', $img, $content); } } } // Get all attached documents of ticket $query = "SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_documents`.`name` AS assocName,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '" . $item->fields['id'] . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' "; if (Session::getLoginUserID()) { $query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true); } else { // Anonymous access from Crontask $query .= " AND `glpi_documents`.`entities_id`= '0' "; } $result = $DB->query($query); if ($DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { if (!empty($data['id'])) { // Image document if (!empty($data['tag'])) { $item->documents[] = $data['id']; } else { if ($CFG_GLPI['attach_ticket_documents_to_mail']) { // Other document $item->documents[] = $data['id']; } } } } } return $content; }
public function postCalcDocs($id) { $user = User::find($id); $documents = User::find($id)->documents; $sum_org_movables_carrying_amount = 0; $sum_org_value_movables_carrying_amount = 0; $sum_org_buildings_carrying_amount = 0; $sum_org_parcels_carrying_amount = 0; $sum_org_movables_residual_value = 0; $sum_org_value_movables_residual_value = 0; $sum_org_buildings_residual_value = 0; $sum_org_cars_carrying_amount = 0; $sum_org_cars_residual_value = 0; foreach ($documents as $document) { $type = $document->os_type; $items = Document::find($document->id)->items; $sum_carrying_amount = 0; $sum_residual_value = 0; foreach ($items as $item) { if (isset($item->carrying_amount)) { $sum_carrying_amount = $sum_carrying_amount + $item->carrying_amount; } else { $sum_carrying_amount = $sum_carrying_amount; } if ($type != 'parcels') { $variable = Item::find($item->id)->variable; if (isset($variable->residual_value)) { $sum_residual_value = $sum_residual_value + $variable->residual_value; } $sum_residual_value = $sum_residual_value; } } $document->doc_carrying_amount = $sum_carrying_amount; if ($type != 'parcels') { $document->doc_residual_value = $sum_residual_value; } $document->save(); if ($type == 'movables') { $sum_org_movables_carrying_amount = $sum_org_movables_carrying_amount + $document->doc_carrying_amount; $sum_org_movables_residual_value = $sum_org_movables_residual_value + $document->doc_residual_value; } if ($type == 'value_movables') { $sum_org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $document->doc_carrying_amount; $sum_org_value_movables_residual_value = $sum_org_value_movables_residual_value + $document->doc_residual_value; } if ($type == 'cars') { $sum_org_cars_carrying_amount = $sum_org_cars_carrying_amount + $document->doc_carrying_amount; $sum_org_cars_residual_value = $sum_org_cars_residual_value + $document->doc_residual_value; } if ($type == 'buildings') { $sum_org_buildings_carrying_amount = $sum_org_buildings_carrying_amount + $document->doc_carrying_amount; $sum_org_buildings_residual_value = $sum_org_buildings_residual_value + $document->doc_residual_value; } if ($type == 'parcels') { $sum_org_parcels_carrying_amount = $sum_org_parcels_carrying_amount + $document->doc_carrying_amount; } } $organization_id = $user->organization_id; $organization = Organization::find($organization_id); $organization->org_movables_carrying_amount = $sum_org_movables_carrying_amount; $organization->org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount; $organization->org_cars_carrying_amount = $sum_org_cars_carrying_amount; $organization->org_buildings_carrying_amount = $sum_org_buildings_carrying_amount; $organization->org_parcels_carrying_amount = $sum_org_parcels_carrying_amount; $organization->org_movables_residual_value = $sum_org_movables_residual_value; $organization->org_value_movables_residual_value = $sum_org_value_movables_residual_value; $organization->org_buildings_residual_value = $sum_org_buildings_residual_value; $organization->org_cars_residual_value = $sum_org_cars_residual_value; $organization->org_carrying_amount = $organization->org_movables_carrying_amount + $organization->org_value_movables_carrying_amount + $organization->org_buildings_carrying_amount + $organization->org_parcels_carrying_amount; $organization->org_residual_value = $organization->org_movables_residual_value + $organization->org_value_movables_residual_value + $organization->org_buildings_residual_value; $organization->save(); return Redirect::action('AdminController@getOrgDocs', [$organization_id]); }
public function printThrough($_id) { $doc = Document::find($_id); $actor = isset(Auth::user()->email) ? Auth::user()->fullname . ' - ' . Auth::user()->email : 'guest'; Event::fire('log.a', array($controller_name, 'print through document', $actor, 'OK')); if ($doc) { $content = file_get_contents($doc->fullpath); print $content; } else { return View::make('shared.notfound'); } }
vertical-align:top; word-break:break-word; } </style> @stop @section('content') <?php //Initializers error_reporting(0); $taskdetails_id = Session::get('taskdetails_id'); Session::forget('taskdetails_id'); $taskd = TaskDetails::find($taskdetails_id); $task = Task::find($taskd->task_id); $doc = Document::find($taskd->doc_id); $purchase = Purchase::find($doc->pr_id); $purchaseToEdit = Purchase::find($doc->pr_id); $date_today = $date_today = date('Y-m-d H:i:s'); //End Initializers ?> {{Session::put('backTo',"task/$taskdetails_id");}} <h2 class="pull-left">Task Details</h2> <div class="pull-right options"> @if($taskd->status == "Active" && $taskd->dueDate > $date_today) <a href="{{ URL::previous() }}" class="btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> Back</a> @elseif($taskd->status == "New") <a href="{{ URL::previous() }}" class="btn btn-default"><span class="glyphicon glyphicon-chevron-left"></span> Back</a>
/** * Show the form for editing the specified branch. * * @param int $id * @return Response */ public function edit($id) { $document = Document::find($id); return View::make('documents.edit', compact('document')); }
function index() { $this->organs = Document::find($_SESSION['document_id'])->organs; }