本文整理汇总了PHP中Sections::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::validate方法的具体用法?PHP Sections::validate怎么用?PHP Sections::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProjectStorages
/**
* Create project shelve and cabinet
* @param $projectId
* @param $year
*/
public static function createProjectStorages($projectId, $year)
{
$project = Projects::model()->findByPk($projectId);
// check existing project cabinet
$cabinet = Storages::model()->findByAttributes(array(
'Storage_Type' => self::CABINET,
'Created_By' => '0',
'Project_ID' => $projectId,
'Year' => $year,
));
if (!$cabinet) {
// if there is not cabinet for this project create it
$cabinet = new Storages();
$cabinet->Storage_Name = $project->Project_Name;
$cabinet->Project_ID = $projectId;
$cabinet->Client_ID = Yii::app()->user->clientID;
$cabinet->Year = $year;
$cabinet->Created_By = 0;
$cabinet->Row_Num = 0;
$cabinet->Storage_Type = self::CABINET;
$cabinet->Access_Type = self::HAS_ACCESS;
if ($cabinet->validate()) {
$cabinet->save();
}
}
// check existing project shelf
$shelf = Storages::model()->findByAttributes(array(
'Storage_Type' => self::SHELF,
'Created_By' => '0',
'Project_ID' => $projectId,
'Year' => $year,
));
if (!$shelf) {
// if there is not cabinet for this project create it
$shelf = new Storages();
$shelf->Storage_Name = $project->Project_Name;
$shelf->Project_ID = $projectId;
$shelf->Client_ID = Yii::app()->user->clientID;
$shelf->Year = $year;
$shelf->Created_By = 0;
$shelf->Row_Num = 0;
$shelf->Storage_Type = self::SHELF;
$shelf->Access_Type = self::HAS_ACCESS;
if ($shelf->validate()) {
$shelf->save();
}
}
$countW9s = W9::getCountOfAvailableW9sOfYear($year);
if ($countW9s > 0) {
// also crete W9 book if it does not exist and there are Company's W9s
$w9Binder = Sections::model()->findByAttributes(array(
'Section_Type' => self::SHELF,
'Created_By' => '0',
'Storage_ID' => $shelf->Storage_ID,
'Folder_Cat_ID' => Sections::W9_BOOK,
));
if (!$w9Binder) {
$w9Binder = new Sections();
$w9Binder->Storage_ID = $shelf->Storage_ID;
$w9Binder->Section_Name = "W9s";
$w9Binder->Vendor_ID = 0;
$w9Binder->Created_By = 0;
$w9Binder->Section_Type = self::SHELF;
$w9Binder->Folder_Cat_ID = Sections::W9_BOOK;
$w9Binder->Access_Type = self::HAS_ACCESS;
if ($w9Binder->validate()) {
$w9Binder->save();
$tab = new Subsections();
$tab->Section_ID = $w9Binder->Section_ID;
$tab->Subsection_Name = 'Tab 1';
$tab->Subsection_Type = self::SHELF;
$tab->Created_By = 0;
$tab->Access_Type = self::HAS_ACCESS;
$tab->save();
}
}
}
}
示例2: createLogBinder
/**
* Create PO Log or Check Log binder for project
* @param $projectId
* @param $docType
* @param $year
* @return int
*/
public static function createLogBinder($projectId, $docType, $year)
{
// get shelf
$shelf = self::getShelfForBinderCreate($projectId, $year);
if ($docType == Documents::PM) {
$folderCatID = self::CHECK_LOG;
} else if ($docType == Documents::PO) {
$folderCatID = self::PURCHASE_ORDER_LOG;
}
$binder = Sections::model()->findByAttributes(array(
'Section_Type' => Storages::SHELF,
'Created_By' => '0',
'Storage_ID' => $shelf->Storage_ID,
'Folder_Cat_ID' => $folderCatID,
));
if (!$binder) {
$binder = new Sections();
$binder->Storage_ID = $shelf->Storage_ID;
if ($docType == Documents::PM) {
$binder->Section_Name = 'Payments';
} else if ($docType == Documents::PO) {
$binder->Section_Name = 'Purchase orders';
}
$binder->Vendor_ID = 0;
$binder->Created_By = 0;
$binder->Section_Type = Storages::SHELF;
$binder->Folder_Cat_ID = $folderCatID;
$binder->Access_Type = Storages::HAS_ACCESS;
if ($binder->validate()) {
$binder->save();
$tab = new Subsections();
$tab->Section_ID = $binder->Section_ID;
$tab->Subsection_Name = 'Tab 1';
$tab->Subsection_Type = Storages::SHELF;
$tab->Created_By = 0;
$tab->Access_Type = Storages::HAS_ACCESS;
$tab->save();
}
} else {
$tab = Subsections::model()->findByAttributes(array(
'Subsection_Type' => Storages::SHELF,
'Created_By' => '0',
'Section_ID' => $binder->Section_ID,
));
}
return $tab->Subsection_ID;
}