本文整理汇总了PHP中Reports::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Reports::fromArray方法的具体用法?PHP Reports::fromArray怎么用?PHP Reports::fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reports
的用法示例。
在下文中一共展示了Reports::fromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromArray
public static function fromArray($data)
{
$settings = new RoleSettings();
foreach ($data as $key => $value) {
if (property_exists(get_class($settings), $key)) {
if (is_array($value)) {
if ($key == "transactions") {
$settings->{$key} = Transactions::fromArray($value);
}
if ($key == "reports") {
$settings->{$key} = Reports::fromArray($value);
}
if ($key == "help") {
$settings->{$key} = Help::fromArray($value);
}
if ($key == "mobileVTAccess") {
$settings->{$key} = MobileVTAcces::fromArray($value);
}
if ($key == "admin") {
$settings->{$key} = Admin::fromArray($value);
}
if ($key == "customer") {
$settings->{$key} = Customers::fromArray($value);
}
if ($key == "webPosAccess") {
$settings->{$key} = WebPosAccess::fromArray($value);
}
} else {
$settings->{$key} = $value;
}
}
}
return $settings;
}
示例2: executeAdd
public function executeAdd(sfWebRequest $request)
{
if ($request->isMethod('post')) {
$name = $request->getParameter('reports')['name'];
if (!$name) {
$this->forwardToSecureAction();
}
if (!in_array($name, array_keys(Reports::getGlobalReports($this->getUser())))) {
$this->info_message = $this->getI18N()->__("You are not allowed to print this kind of report.");
return $this->renderPartial("info_msg", array("info_message" => $this->info_message));
}
$default_vals = array();
foreach ($request->getRequestParameters() as $rp_key => $rp_value) {
if (strpos($rp_key, 'default_vals[') !== false && strpos($rp_key, ']') !== false && strpos($rp_key, ']') - strpos($rp_key, '[') > 1) {
$default_vals[substr($rp_key, strpos($rp_key, '[') + 1, strpos($rp_key, ']') - strpos($rp_key, '[') - 1)] = $rp_value;
}
}
$this->setWidgetsOptions($name);
$this->form = new ReportsForm(null, array('fields' => $this->widgets, 'name' => $name, 'model_name' => $request->getParameter('catalogue', 'taxonomy'), 'with_js' => $request->getParameter('with_js', false), 'default_vals' => $default_vals, 'current_user' => $this->getUser()));
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
if (isset($request->getParameter('reports')['loan_id']) && count(Doctrine::getTable('Loans')->getPrintableLoans(array($request->getParameter('reports')['loan_id']), $this->getUser())) == 0) {
$this->info_message = $this->getI18n()->__("You don't have the necessary credentials to print this loan");
} else {
$this->info_message = $this->getI18n()->__("Your report has been saved. It will be availlable tomorrow");
$report = new Reports();
$report->fromArray(array('name' => $name, 'user_ref' => $this->getUser()->getId(), 'lang' => $this->getUser()->getCulture(), 'format' => $request->getParameter('reports')['format'], 'comment' => $request->getParameter('reports')['comment']));
$report->setParameters($request->getParameter('reports'));
// Save the report whatever it's a fast or a non fast one
$report->save();
//if it's a fast report, it can be downloaded directly
if (Reports::getIsFast($name)) {
$response = $this->processDownload($report);
if ($response != 0) {
$message = json_encode($this->getPartial("info_msg", array("info_message" => $this->info_message)));
return $this->renderText('{ "report_url" : "' . $this->generateUrl("default", array("module" => "report", "action" => "downloadFile", "id" => $response), TRUE) . '", "message": ' . $message . ' }');
}
}
}
return $this->renderPartial("info_msg", array("info_message" => $this->info_message));
}
$val = $this->renderPartial("report_form", array('form' => $this->form, 'fields' => $this->widgets, 'fields_options' => $this->widgets_options, 'fields_at_second_line' => $this->widgets_second_line_count, 'model_name' => $request->getParameter('catalogue', 'taxonomy'), 'fast' => Reports::getIsFast($name), 'with_js' => $request->getParameter('with_js', false), 'default_vals' => $default_vals));
return $val;
}
}