public function execute() { $model = new waModel(); $payment_model = new wacabPaymentModel(); $payments = $payment_model->getAll(); $apps_model = new wacabAppsModel(); $apps = $apps_model->getByField('stat', 1, true); $total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` is not null')->fetchAll(); $plugins_stat = array(); foreach ($apps as $app) { $app_total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` = ' . $app['id'])->fetch(); $app_count = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` >= 0 AND `apps_id` = ' . $app['id'])->fetch(); $app_return = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` < 0 AND `apps_id` = ' . $app['id'])->fetch(); $names = json_decode($app['name'], true); if ($app['parent'] == 'no_parent' || $app['parent'] == '') { $pname = $names[0]; } else { $pname = $names[0] . " (" . $app['parent'] . ")"; } $plugins_stat[] = array('id' => $app['app_id'], 'total' => $app_total[0], 'name' => $pname, 'count' => $app_count[0], 'return' => $app_return[0]); } $this->view->assign('total', $total); $this->view->assign('apps', $plugins_stat); $this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/statistic/stat_page.html'); }
public static function checkApps($pay) { $apps_model = new wacabAppsModel(); $no_parent_apps = $apps_model->getByField('parent', 'no_parent', true); $spds = array('Начисление за ', 'Royalty fee for '); $tmp = 0; foreach ($no_parent_apps as $akey => $app) { $app_locs = json_decode($app['name']); foreach ($app_locs as $app_loc) { if (strpos($pay['description'], $app_loc)) { foreach ($spds as $spd) { if ($spd . $app_loc == $pay['description']) { return $app['id']; // $pay['apps_id'] = $app['id']; // break 3; } } $plugins = $apps_model->getByField('parent', $app['app_id'], true); foreach ($plugins as $pkey => $plugin) { $plugin_locs = json_decode($plugin['name']); foreach ($plugin_locs as $plugin_name) { if (strpos($pay['description'], $plugin_name)) { if (strlen($app_loc) > $tmp) { $tmp = strlen($app_loc); $apps_id = $plugin['id']; } } } } } } } if ($tmp > 0) { return $apps_id; // $pay['apps_id'] = $apps_id; // unset($apps_id); } return; }