本文整理汇总了PHP中Documents::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Documents::getErrors方法的具体用法?PHP Documents::getErrors怎么用?PHP Documents::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Documents
的用法示例。
在下文中一共展示了Documents::getErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
*/
public function actionCreate()
{
// create Comments Object
$model = new Comments();
// if Comments form exist
if (isset($_POST['Comments'])) {
// set form elements to Comments model attributes
$model->attributes = $_POST['Comments'];
$module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
// set module_id finded to model
$model->module_id = $module->module_id;
$project = Yii::app()->user->getState('project_selected');
$model->project_id = $project;
// validate and save
if ($model->save()) {
// create an instance of file uploaded
$image = CUploadedFile::getInstancesByName('Comment');
// if file upload exist
if (count($image > 0)) {
// for each file uploaded
for ($i = 0; $i < count($image); $i++) {
// create an Document object
$modeldocs = new Documents();
$modeldocs->image = $image[$i];
if (!$modeldocs->image->getError()) {
// name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
$this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
// set the extension file uploaded
$extension = $modeldocs->image->getExtensionName();
// if no error saving file
if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
$modeldocs->project_id = $project;
$modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
$modeldocs->document_description = $model->comment_text;
$modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
$modeldocs->document_revision = '1';
$modeldocs->document_uploadDate = date("Y-m-d");
$modeldocs->document_type = $modeldocs->image->getType();
$modeldocs->document_baseRevision = date('dmYHis');
$modeldocs->user_id = Yii::app()->user->id;
$modeldocs->comment_id = $model->primaryKey;
// save file uploaded as document
if ($modeldocs->save()) {
Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
}
}
}
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
Logs::model()->saveLog($attributes);
// find project managers to sent comment via mail
$recipientsList = array();
$ProjectManagers = Projects::model()->findManagersByProject($project);
$managersArray = array();
foreach ($ProjectManagers as $manager) {
$managersArray['email'] = $manager->user_email;
$managersArray['name'] = $manager->CompleteName;
array_push($recipientsList, $managersArray);
}
// find task owners to send comment via mail
if ($module->module_name == 'tasks') {
$collaborators = Projects::model()->findAllUsersByProject($project);
$ColaboratorsArray = array();
foreach ($collaborators as $colaborator) {
$ColaboratorsArray['email'] = $colaborator->user_email;
$ColaboratorsArray['name'] = $colaborator->CompleteName;
// avoid to repeat email address
if (!in_array($ColaboratorsArray, $recipientsList)) {
array_push($recipientsList, $ColaboratorsArray);
}
}
}
// finding resource title
switch ($module->module_name) {
case "budgets":
$resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
break;
case "invoices":
$resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
break;
case "expenses":
$resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
break;
case "documents":
$resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
break;
case "milestones":
$resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
break;
//.........这里部分代码省略.........
示例2: loadAndSave
public static function loadAndSave($personid, $objarr)
{
foreach ($objarr as $item) {
$val = (object) $item;
if ($val->id_Type == 4) {
$doc = new Documents();
$doc->scenario = "FULLINPUT";
$doc->PersonID = $personid;
$doc->TypeID = $val->id_Type;
$doc->edboID = $val->id_Document;
$doc->AtestatValue = $val->attestatValue;
$doc->Numbers = $val->number;
$doc->Series = $val->series;
$doc->DateGet = date("d.m.Y", mktime(0, 0, 0, $val->dateGet['month'] + 1, $val->dateGet['dayOfMonth'], $val->dateGet['year']));
$doc->ZNOPin = $val->znoPin;
$doc->Issued = $val->issued;
if ($val->dateGet['year'] < date("Y")) {
Yii::log("Пропущено сертификат {$doc->Numbers} " . $val->dateGet['year'] . " года!");
continue;
}
if ($doc->save() && !empty($val->subjects)) {
foreach ($val->subjects as $valstr) {
$item = (object) $valstr;
$subj = new Documentsubject();
$subj->DateGet = $doc->DateGet;
$subj->edboID = $item->id_DocumentSubject;
$subj->DocumentID = $doc->idDocuments;
$subj->SubjectID = $item->id_Subject;
$subj->SubjectValue = $item->subjectValue;
$subj->save();
}
}
} else {
if ($val->id_Type == 11 || $val->id_Type == 12 || $val->id_Type == 13 || $val->id_Type == 2) {
$exdoc = null;
try {
if (empty($exdoc)) {
$doc = new Documents();
//$doc->scenario = "FULLINPUT";
$doc->PersonID = $personid;
$doc->TypeID = $val->id_Type;
$doc->edboID = $val->id_Document;
$doc->AtestatValue = $val->attestatValue;
$doc->Numbers = $val->number;
$doc->Series = $val->series;
$doc->DateGet = date("d.m.Y", mktime(0, 0, 0, $val->dateGet['month'] + 1, $val->dateGet['dayOfMonth'], $val->dateGet['year']));
//$doc->ZNOPin = $val->znoPin;
$doc->Issued = $val->issued;
if (!$doc->save()) {
throw new Exception(print_r($doc->getErrors(), 1));
}
}
} catch (Exception $exc) {
Yii::log($exc->getMessage());
}
} else {
if (Yii::app()->user->checkAccess("asEDBOReqOperator")) {
try {
if (empty($exdoc)) {
$doc = new Documents();
$doc->scenario = "FULLINPUT";
$doc->PersonID = $personid;
$doc->TypeID = $val->id_Type;
$doc->edboID = $val->id_Document;
$doc->AtestatValue = $val->attestatValue;
$doc->Numbers = $val->number;
$doc->Series = $val->series;
$doc->DateGet = date("d.m.Y", mktime(0, 0, 0, $val->dateGet['month'] + 1, $val->dateGet['dayOfMonth'], $val->dateGet['year']));
//$doc->ZNOPin = $val->znoPin;
$doc->Issued = $val->issued;
if (!$doc->save()) {
throw new Exception(print_r($doc->getErrors()));
}
}
} catch (Exception $exc) {
Yii::log($exc->getMessage());
}
}
}
}
}
}