本文整理汇总了PHP中Docs::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Docs::model方法的具体用法?PHP Docs::model怎么用?PHP Docs::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Docs
的用法示例。
在下文中一共展示了Docs::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Docs::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: ini
private function ini()
{
if (!$this->ini) {
$this->_precision = Yii::app()->user->getSetting('company.precision');
$this->iVatRate = Item::model()->findByPK($this->item_id)->vat;
$this->rate = Currates::model()->GetRate($this->currency_id);
if ($this->doc_rate == 0) {
$doc = Docs::model()->findByPk($this->doc_id);
$this->doc_rate = Currates::model()->GetRate($doc->currency_id);
}
$this->ini != $this->ini;
}
}
示例3: getTemplateModel
/**
* Magic getter for {@link templateModel}
* @return type
*/
public function getTemplateModel($id = null)
{
$newTemp = !empty($id);
if ($newTemp) {
$this->template = $id;
$this->_templateModel = null;
} else {
$id = $this->template;
}
if (empty($this->_templateModel)) {
$this->_templateModel = Docs::model()->findByPk($id);
}
return $this->_templateModel;
}
示例4: actionAjaxCheckEditPermission
/**
* Echoes 'true' if User has permission, 'false' otherwise
* @param int id id of doc model
*/
public function actionAjaxCheckEditPermission($id)
{
if (!isset($id)) {
echo 'failure';
return;
}
$doc = Docs::model()->findByPk($id);
if (isset($doc)) {
$canEdit = $doc->checkEditPermissions() ? 'true' : 'false';
} else {
$canEdit = 'false';
}
echo $canEdit;
return;
}
示例5: make
public function make()
{
$this->id = rand(0, 999999);
//$this->iniArr=array('b110'=>0,'b100'=>0,'m100'=>0,'c100'=>0,'d100'=>0,'d110'=>0,'d120'=>0,);
//$this->docArr=array(0=>0,305=>0,300=>0,);
$bkmv = '';
//$this->line=1;
$yiidatetimesec = Yii::app()->locale->getDateFormat('yiidatetimesec');
$phpdbdatetime = Yii::app()->locale->getDateFormat('phpdbdatetime');
$from_date = date($phpdbdatetime, CDateTimeParser::parse($this->from_date . ":00", $yiidatetimesec));
$to_date = date($phpdbdatetime, CDateTimeParser::parse($this->to_date . ":00", $yiidatetimesec));
//$types=array(3,4,9,11,13,14);
//accounts
$criteria = new CDbCriteria();
$accounts = Accounts::model()->findAll($criteria);
$record = array('id' => 'B110', 'name' => OpenFormatType::model()->getDesc('B110'), 'count' => 0);
foreach ($accounts as $account) {
$this->line++;
$bkmv .= $account->openfrmt($this->line, $from_date, $to_date);
$record['count']++;
}
$this->iniArr[] = $record;
//items
$criteria = new CDbCriteria();
$items = Item::model()->findAll($criteria);
$record = array('id' => 'M100', 'name' => OpenFormatType::model()->getDesc('M100'), 'count' => 0);
foreach ($items as $item) {
$this->line++;
$bkmv .= $item->openfrmt($this->line, $from_date, $to_date);
$record['count']++;
}
$this->iniArr[] = $record;
//
//transactions
$criteria = new CDbCriteria();
$criteria->condition = "valuedate BETWEEN :from_date AND :to_date";
$criteria->params = array(':from_date' => $from_date, ':to_date' => $to_date);
$transactions = Transactions::model()->findAll($criteria);
$record = array('id' => 'B100', 'name' => OpenFormatType::model()->getDesc('B100'), 'count' => 0);
foreach ($transactions as $transaction) {
$this->line++;
$bkmv .= $transaction->openfrmt($this->line, $from_date, $to_date);
$record['count']++;
}
$this->iniArr[] = $record;
//docs
$criteria = new CDbCriteria();
$criteria->condition = "due_date BETWEEN :from_date AND :to_date";
$criteria->params = array(':from_date' => $from_date, ':to_date' => $to_date);
$docs = Docs::model()->findAll($criteria);
//OpenFormatType::model()->getDesc('C100')
$record = array('id' => 'C100', 'name' => OpenFormatType::model()->getDesc('C100'), 'count' => 0);
$d110 = array('id' => 'D110', 'name' => OpenFormatType::model()->getDesc('D110'), 'count' => 0);
$d120 = array('id' => 'D120', 'name' => OpenFormatType::model()->getDesc('D120'), 'count' => 0);
foreach ($docs as $doc) {
if ($doc->docType->openformat != '0') {
$this->line++;
$bkmv .= $doc->openfrmt($this->line, $from_date, $to_date);
foreach ($doc->docDetailes as $detial) {
$this->line++;
$bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
$d110['count']++;
}
foreach ($doc->docCheques as $detial) {
$this->line++;
$bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
$d120['count']++;
}
$type = $doc->getType();
$this->docArr[$type] = isset($this->docArr[$type]) ? $this->docArr[$type] + 1 : 0;
$this->docSumArr[$type] = isset($this->docSumArr[$type]) ? $this->docSumArr[$type] + $doc->total : $doc->total;
$record['count']++;
}
}
$this->iniArr[] = $record;
$this->iniArr[] = $d110;
$this->iniArr[] = $d120;
$company = Settings::model()->findByPk('company.name');
//A100
$bkmv = $company->a100(1, $this->id) . $bkmv;
//Z900
$bkmv = $bkmv . $company->z900($this->line + 1, $this->id, $this->line + 1);
$bkmvFile = new Files();
$bkmvFile->name = 'bkmvdata.txt';
$bkmvFile->path = 'openformat/';
//
$bkmvFile->expire = 360;
$bkmvFile->save();
$bkmvFile->writeFile($bkmv);
$this->bkmvId = $bkmvFile->id;
//A000
$ini = $company->a000(1, $this->id, $this->line + 1);
foreach ($this->iniArr as $line) {
$ini .= $line['id'] . sprintf("%015d", $line['count']) . "\r\n";
}
//Z
$iniFile = new Files();
$iniFile->name = 'ini.txt';
$iniFile->path = 'openformat/';
//
//.........这里部分代码省略.........
示例6: globalExport
private function globalExport()
{
$file = 'data.csv';
$fp = fopen($file, 'w+');
$modules = Modules::model()->findAll();
$pieces = array();
foreach ($modules as $module) {
$pieces[] = $module->name;
}
$tempArr = array();
foreach ($pieces as $model) {
if ($model == "quotes") {
$model = "quote";
}
if ($model == "products") {
$model = "product";
}
if ($model == 'marketing') {
$model = "campaign";
}
if ($model != 'dashboard' && $model != 'calendar' && is_null(Docs::model()->findByAttributes(array('title' => $model)))) {
$tempArr[ucfirst($model)] = CActiveRecord::model(ucfirst($model))->findAll();
}
}
$tempArr['Profile'] = ProfileChild::model()->findAll();
$labels = array();
foreach ($tempArr as $model => $data) {
$temp = CActiveRecord::model($model);
$tempKeys = array_keys($temp->attributes);
$tempKeys[] = $model;
$labels[$model] = $tempKeys;
}
fputcsv($fp, array(Yii::app()->params->version));
$keys = array_keys($tempArr);
for ($i = 0; $i < count($tempArr); $i++) {
$meta = $labels[$keys[$i]];
fputcsv($fp, $meta);
foreach ($tempArr[$keys[$i]] as $data) {
$tempAtr = $data->attributes;
$tempAtr[] = $keys[$i];
fputcsv($fp, $tempAtr);
}
}
fclose($fp);
}
示例7: retitle
/**
* Renames module
* @param string $newTitle
* @return bool true for success, false for failure
*/
public function retitle($newTitle)
{
$oldTitle = $this->title;
$this->title = $newTitle;
if ($this->save()) {
// if it's a static page, rename the doc too
if ($this->name === 'document') {
$doc = Docs::model()->findByAttributes(array('name' => $oldTitle));
$doc->name = $this->title;
$doc->save();
}
// Clear cached display names
self::$_displayNames = array();
return true;
} else {
return false;
}
}
示例8: getChildren
private function getChildren($option = null)
{
$children = array('folders' => array(), 'docs' => array());
$folderCriteria = new CDbCriteria();
if ($option === 'root') {
$folderCriteria->condition = 'parentFolder IS NULL AND id > 0';
} else {
$folderCriteria->compare('parentFolder', $this->id);
}
$folderCriteria->mergeWith($this->getAccessCriteria());
$folderCriteria->order = 'name ASC';
$children['folders'] = DocFolders::model()->findAll($folderCriteria);
$docsCriteria = new CDbCriteria();
$doc = Docs::model();
if ($option === 'root') {
$docsCriteria->condition = 'folderId IS NULL AND type NOT IN ("email","quote")';
} elseif ($option === self::TEMPLATES_FOLDER_ID) {
$docsCriteria->condition = 'folderId IS NULL AND type IN ("email","quote")';
} else {
$docsCriteria->compare('folderId', $this->id);
}
$docsCriteria->mergeWith($doc->getAccessCriteria());
$docsCriteria->order = 'name ASC';
$children['docs'] = Docs::model()->findAll($docsCriteria);
return $children;
}
示例9: actionDeleteFileFolder
public function actionDeleteFileFolder()
{
if (Yii::app()->request->isAjaxRequest && isset($_POST['type'], $_POST['id'])) {
if ($_POST['type'] === 'folder') {
$model = DocFolders::model()->findByPk($_POST['id']);
if (is_null($model)) {
throw new CHttpException(404, 'Folder not found.');
}
if (!$model->checkRecursiveDeletePermissions()) {
$this->denied();
}
} elseif ($_POST['type'] === 'doc') {
$model = Docs::model()->findByPk($_POST['id']);
if (is_null($model)) {
throw new CHttpException(404, 'File not found.');
}
if (!$this->checkPermissions($model, 'delete')) {
$this->denied();
}
} else {
throw new CHttpException(400, 'Bad request.');
}
$model->delete();
} else {
throw new CHttpException(400, 'Bad request.');
}
}
示例10: array
<?php
/* * *********************************************************************************
* The contents of this file are subject to the Mozilla Public License Version 2.0
* ("License"); You may not use this file except in compliance with the Mozilla Public License Version 2.0
* The Original Code is: Linet 3.0 Open Source
* The Initial Developer of the Original Code is Adam Ben Hur.
* All portions are Copyright (C) Adam Ben Hur.
* All Rights Reserved.
* ********************************************************************************** */
// this is the date picker
$dateisOn = $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Docs[issue_from]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->issue_from, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'From Date'))), true) . $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Docs[issue_to]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->issue_to, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'To Date'))), true);
?>
<?php
$filter = '';
if ($model->doctype != null) {
$filter = CHtml::listData(Docstatus::model()->findAllByAttributes(array('doc_type' => $model->doctype)), 'num', 'name');
} else {
$model->status = null;
}
//print_r(Yii::app()->locale);
$this->widget('EExcelView', array('id' => 'Docs', 'dataProvider' => $model->search(), 'filter' => $model, 'ajaxUpdate' => true, 'ajaxType' => 'POST', 'afterAjaxUpdate' => "function() {\n\t\t\t\t\t\tjQuery('#Docs_issue_from').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n\t\t\t\t\t\tjQuery('#Docs_issue_to').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n }", 'columns' => array(array('name' => 'doctype', 'filter' => Doctype::model()->getList(), 'value' => '$data->getTypeName()', 'htmlOptions' => array('style' => 'width:20%;')), array('name' => 'status', 'filter' => $filter, 'value' => '$data->getStatus()'), array('name' => 'refstatus', 'filter' => CHtml::listData(Docs::model()->getRefStatuses(), 'id', 'name'), 'value' => '$data->getRefStatus()'), array('name' => 'docnum', 'htmlOptions' => array('style' => 'width:8%;')), array('name' => 'account_id', 'htmlOptions' => array('style' => 'width:8%;')), 'company', array('name' => 'issue_date', 'filter' => $dateisOn, 'value' => '$data->issue_date', 'htmlOptions' => array('style' => 'width:15%;')), array('name' => 'total', 'htmlOptions' => array('style' => 'width:8%;')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'htmlOptions' => array('style' => 'width:80px'), 'template' => '{duplicate}{print}{edit}{delete}{display}', 'buttons' => array('duplicate' => array('label' => '<i class="glyphicon glyphicon-plus-sign"></i>', 'url' => 'Yii::app()->createUrl("docs/duplicate/". $data->id)'), 'edit' => array('label' => '<i class="glyphicon glyphicon-edit"></i>', 'url' => 'Yii::app()->createUrl("docs/update", array("id"=>$data->id))'), 'delete' => array('label' => '<i class="glyphicon glyphicon-remove"></i>', 'deleteConfirmation' => true, 'imageUrl' => false, 'url' => 'Yii::app()->createUrl("docs/delete", array("id"=>$data->id))'), 'print' => array('label' => '<i class="glyphicon glyphicon-print"></i>', 'url' => 'Yii::app()->createUrl("docs/print", array("id"=>$data->id))', 'options' => array("target" => "_blank")), 'display' => array('label' => '<i class="glyphicon glyphicon-search"></i>', 'url' => 'Yii::app()->createUrl("docs/view", array("id"=>$data->id))'))))));
示例11: init
public function init()
{
$this->disableTemplates = $this->disableTemplates || in_array($this->associationType, array_keys(Docs::modelsWhichSupportEmailTemplates()));
// Prepare the model for initially displayed input:
$this->model = new InlineEmail();
if (isset($this->targetModel)) {
$this->model->targetModel = $this->targetModel;
}
if (!$this->associationType) {
$this->associationType = X2Model::getModelName(Yii::app()->controller->module->name);
}
// Bring in attributes set in the configuration:
$this->model->attributes = $this->attributes;
if (empty($this->template)) {
// check for a default template
$defaultTemplateId = Yii::app()->params->profile->getDefaultEmailTemplate(Yii::app()->controller->module->name);
// if there's a default set for this module
if ($defaultTemplateId !== null) {
$defaultTemplateDoc = Docs::model()->findByPk($defaultTemplateId);
// ensure that template is still a valid default
if ($defaultTemplateDoc && ($defaultTemplateDoc->associationType === $this->associationType || $defaultTemplateDoc->type === 'quote' && $this->model->targetModel instanceof Quote)) {
$this->template = $defaultTemplateId;
}
}
}
if (empty($this->template)) {
if (empty($this->model->message)) {
$this->model->message = InlineEmail::emptyBody();
}
$this->model->insertSignature();
} else {
// Fill in the body with a template:
$this->model->scenario = 'template';
if (!empty($this->template)) {
$this->model->template = $this->template;
}
$this->model->prepareBody();
}
// If insertable attributes aren't set, use the inline email model's
// getInsertableAttributes() method to generate them.
if ((bool) $this->model->targetModel && !isset($this->insertableAttributes)) {
$this->insertableAttributes = $this->model->insertableAttributes;
}
$this->registerJSClassInstantiation();
// Load resources:
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/ckeditor/ckeditor.js');
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/ckeditor/adapters/jquery.js');
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/emailEditor.js');
if (!empty($this->insertableAttributes)) {
Yii::app()->clientScript->registerScript('setInsertableAttributes', 'x2.insertableAttributes = ' . CJSON::encode($this->insertableAttributes) . ';', CClientScript::POS_HEAD);
}
Yii::app()->clientScript->registerScript('storeOriginalInlineEmailMessage', 'x2.inlineEmailOriginalBody = $("#email-message").val();', CClientScript::POS_READY);
//'.CJSON::encode($this->model->message).';',CClientScript::POS_READY);
Yii::app()->clientScript->registerScript('toggleEmailForm', $this->startHidden ? "window.hideInlineEmail = true;\n" : "window.hideInlineEmail = false;\n", CClientScript::POS_HEAD);
$this->registerPackages();
parent::init();
}
示例12: actionIndex
public function actionIndex()
{
$docs = Docs::model()->with("Students")->findAll();
$this->render("index", array("docs" => $docs));
}
示例13: refnumDocsLink
public function refnumDocsLink()
{
$str = '';
$array = explode(",", $this->refnum1);
foreach ($array as $docid) {
$doc = Docs::model()->findByPk($docid);
if ($doc !== null) {
$str .= CHtml::link(CHtml::encode(Yii::t('app', $doc->docType->name) . " #" . $doc->docnum), Yii::app()->createAbsoluteUrl("/docs/view/{$docid}"));
} else {
$str .= $docid;
}
$str .= ",";
//echo $docid;
}
return rtrim($str, ",");
}
示例14: saveRef
public function saveRef($id, $total)
{
$str = $this->refnum;
//save new values
$sum = 0;
$tmp = explode(",", rtrim($str, ","));
foreach ($tmp as $id) {
//lets do this
//if($id==$this->id){
// throw new CHttpException(500,Yii::t('app','You cannot save doc as a refnum'));
//}
$doc = Docs::model()->findByPk((int) $id);
if ($doc !== null) {
$sum += $doc->total;
//adam: need to multi currency!
if ($sum <= $total) {
$doc->refstatus = Docs::STATUS_CLOSED;
} else {
$doc->refstatus = Docs::STATUS_OPEN;
}
$doc->refnum = $id;
$doc->save();
}
}
//$this->refnum=$str;
}
示例15: execute
/**
* @param array $gvSelection array of ids of records to perform mass action on
*/
public function execute(array $gvSelection)
{
if (Yii::app()->controller->modelClass !== 'Docs' || count($gvSelection) > 1 || !isset($_POST['selectedObjs']) || !is_array($_POST['selectedObjs']) || count($_POST['selectedObjs']) !== count($gvSelection) || !isset($_POST['selectedObjTypes']) || !is_array($_POST['selectedObjTypes']) || count($_POST['selectedObjTypes']) !== count($gvSelection) || !in_array($_POST['selectedObjTypes'][0], array('doc', 'folder')) || !isset($_POST['newName'])) {
throw new CHttpException(400, Yii::t('app', 'Bad Request'));
}
$selectedObjId = array_pop($_POST['selectedObjs']);
$type = array_pop($_POST['selectedObjTypes']);
$newName = $_POST['newName'];
if ($type === 'doc') {
$obj = Docs::model()->findByPk($selectedObjId);
} else {
// $type === 'folder'
$obj = DocFolders::model()->findByPk($selectedObjId);
}
if (!$obj) {
self::$errorFlashes[] = Yii::t('app', 'Selected {type} does not exist', array('{type}' => $type === 'doc' ? ucfirst($type) : $type));
return 0;
}
if (!Yii::app()->controller->checkPermissions($obj, 'edit')) {
self::$errorFlashes[] = Yii::t('app', 'You do not have permission to edit this {type}.', array('{type}' => $type === 'doc' ? ucfirst($type) : $type));
return 0;
}
if ($type === 'doc' && !Yii::app()->params->isAdmin && !in_array('name', Docs::model()->getEditableAttributeNames())) {
self::$errorFlashes[] = Yii::t('app', 'You do not have permission to rename Docs.');
return 0;
}
$obj->name = $newName;
$successes = 0;
if ($obj->save(true, array('name'))) {
self::$successFlashes[] = Yii::t('app', 'Renamed {type}', array('{type}' => $type === 'doc' ? ucfirst($type) : $type));
$successes = 1;
} else {
self::$errorFlashes[] = Yii::t('app', 'Failed to renamed {type}', array('{type}' => $type === 'doc' ? ucfirst($type) : $type));
}
return $successes;
}