/** * Insert new document * @param [type] $document [description] * @param array $options [description] * @return [type] [description] */ public function insert(&$data, array $options = array()) { $document = new Document($data, $this); $insert = $document->insert($options); $data = $document->data; return $insert; }
logMessage("WorkerDocumentUploadPage", "upload error:{$errorMessage}"); $_SESSION[PARAM_PAGE_MESSAGE] = $errorMessage; header('Location: WorkerDocumentUploadPage.php'); include 'WorkerDocumentUploadPage.php'; return; } // else we are good to go $expo = getExpoCurrent(); $worker = getWorkerCurrent(); $doc = new Document(); $doc->workerid = $worker->workerid; $doc->expoid = $expo->expoid; try { $fileString = file_get_contents($_FILES[PARAM_DOCUMENT]['tmp_name']); $doc->docType = $_SESSION[PARAM_DOCTYPE]; $doc->docMime = $_FILES[PARAM_DOCUMENT]['type']; $doc->docName = $_FILES[PARAM_DOCUMENT]['name']; $doc->content = $fileString; ${$fileString} = NULL; $doc->insert(); // can throw PDOException $_SESSION[PARAM_PAGE_MESSAGE] = "Your document has uploaded successfully."; } catch (Exception $ex) { $msg = $ex->getMessage(); logMessage("WorkerDocumentUploadAction", "file error:{$msg}"); $_SESSION[PARAM_PAGE_MESSAGE] = "Your document has failed to upload."; } $doc = NULL; // gc hint header('Location: WorkerDocumentUploadPage.php'); include 'WorkerDocumentUploadPage.php';
if ($mode == "Add") { # echo "<pre>"; print_r($_FILES) ; exit; $redirect_file = "index.php?file=m-documentadd" . $qs . "&iLibCategoryId=" . $iLibCategoryId; $GeneralObj->checkDuplicate('iDocumentId', 'Document', array('vDocumentName', 'iLibCategoryId'), $redirect_file, "Document Name Already Exists ", $vVideoName, ' AND '); // $documentObj->setdCreated($dCreated); if (isset($_FILES['vDocumentpath']['name']) && $_FILES['vDocumentpath']['name'] != "") { $pdf_name = date('Ymdhis') . $_FILES['vDocumentpath']['name']; if (copy($_FILES['vDocumentpath']['tmp_name'], $CFG->datadirroot . "/pdf/" . $pdf_name)) { if ($pdf_name != '') { $documentObj->setvDocumentpath($pdf_name); } } } #echo $pdf_name.'##'; exit; //$documentObj->setiSGroupId($iSGroupId); $id1 = $documentObj->insert(); $msg = MSG_ADD; if ($eStatus == 'Active') { // for Notification of users $sql_Category_select = "select vCategoryName FROM LibraryCategory WHERE iLibCategoryId = " . $iLibCategoryId; $catagery_Array = $obj->select($sql_Category_select); $user_emails = $userObj->getNotificationUsers($iSGroupId); if (is_Array($user_emails) && count($user_emails) > 0) { for ($i = 0; $i < count($user_emails); $i++) { // $emailObj->send_add_documentmail($user_emails[$i]['vUsername'],$vDocumentName,$user_emails['admin_email'],$user_emails[$i]['vEmail'],$catagery_Array[0]['vCategoryName']); $sql_insert = "INSERT INTO `cron_email` (`vEmail` ,`vUsername` ,`vName` ,`vAdmin_email` ,`vCategoryName` ,`eType` ,`iID`)\n\t\t\t\t\t\tVALUES ('" . $user_emails[$i]['vEmail'] . "', '" . $user_emails[$i]['vUsername'] . "', '" . $vDocumentName . "', '" . $user_emails['admin_email'] . "', '" . $catagery_Array[0]['vCategoryName'] . "', 'Document', '" . $id1 . "')"; //echo $sql_insert;exit; $id = $obj->insert($sql_insert); /* $to = ''.$user_emails[$i]['vEmail'].''; $subject = 'New Document added - Check it out';
function showDocs() { global $connector; global $result; $course = new Course(); $doc = new Document(); $course->setConnector($connector); $doc->setConnector($connector); if (isset($_POST['operation'])) { list($operation, $params) = explode("#", $_POST['operation']); switch ($operation) { case 'saveChanges': $doc->storeFormValues($_POST, BASE_PATH . "/upload/"); $error_msg = $doc->insert(); break; case 'delete': $error_msg = $doc->delete($params); break; default: $error_msg = "Operazione non valida"; } if ($error_msg != "") { $result["errorMessage"] = $error_msg; } elseif ($operation != 'edit') { $result["statusMessage"] = "Operazione completata!"; } } $result["courses"] = $course->getList("nome"); $result['docs'] = $doc->getList(); $page = "document.php"; include_once BASE_PATH . "template.php"; }
<?php /** * Classe de test pour l'entité Document */ include_once '../Database.php'; include_once '../Document.php'; // Création d'un document echo "Création d'un document ... "; $document = new Document(); $document->debut = "2015-12-28"; $document->fin = "2015-12-29"; $document->id_appartement = 1; // Ajout dans la base echo "OK<br/>Ajout du document dans la base ... "; $document->insert(); echo "OK<br/>"; // Liste de tous les documents listerTout(); // Apport d'une modification $document->fin = "2015-12-30"; echo "Modification de la fin ! Mise à jour dans la base ... "; $document->update(); echo "OK<br/>"; // Sélection de l'appartement $selectionDocument = Document::findById($document->id_document); $selectionDocument->afficher(); // Suppression du document echo "Suppression du document de la base ... "; $selectionDocument->delete(); echo "OK<br/>";