Beispiel #1
0
$this->getTemplate()->setBlock('middle', 'general/middle.phtml');
$this->getTemplate()->setBlock('footer_a', 'general/footer_a.phtml');
$this->getTemplate()->setBlock('footer', 'general/footer.phtml');
switch ($_REQUEST['action']) {
    case 'jCompanyList':
        if (array_key_exists('filter', $_REQUEST)) {
            if (array_key_exists('capitaleSociale', $_REQUEST['filter'])) {
                $_REQUEST['filter']['capitaleSociale'] = urldecode($_REQUEST['filter']['capitaleSociale']);
                if (strpos($_REQUEST['filter']['capitaleSociale'], ',') !== false) {
                    $_REQUEST['filter']['capitaleSociale'] = explode(',', $_REQUEST['filter']['capitaleSociale']);
                }
            }
        }
        $companyColl = new \crm\CompanyColl($GLOBALS['db']);
        $companyColl->loadAll(array_merge(array('page' => 0, 'count' => 10), $_REQUEST));
        $result = array('count' => $companyColl->countAll($_REQUEST), 'data' => array());
        foreach ($companyColl->getItems() as $company) {
            $result['data'][] = $company->getData();
        }
        header('Content-Type: application/json');
        echo json_encode($result);
        exit;
        break;
    case 'edit':
        $company = new \crm\Company($GLOBALS['db']);
        $company->loadFromId($_REQUEST['partIVA']);
        $this->getTemplate()->setObjectData($company);
        $this->getTemplate()->setBlock('middle', 'company/edit.phtml');
        $this->getTemplate()->setBlock('footer', 'company/footer.phtml');
        $this->getTemplate()->setBlock('footer_a', 'general/footer_a.phtml');
        break;