예제 #1
0
$companyUrl = Tools::param('companyUrl');
$rowStyle = Tools::param('rowStyle');
$rowId = Tools::param('rowId');
$newCompanyModel = null;
try {
    $companyModel = new CompanyModel();
    $companyModel->setAgencyCompanyId($agencyCompanyId);
    $companyModel->setCompanyName($companyName);
    $companyModel->setCompanyAddress1($companyAddress1);
    $companyModel->setCompanyAddress2($companyAddress2);
    $companyModel->setCompanyCity($companyCity);
    $companyModel->setCompanyState($companyState);
    $companyModel->setCompanyZip($companyZip);
    $companyModel->setCompanyPhone($companyPhone);
    $companyModel->setCompanyUrl($companyUrl);
    $companyController = new CompanyController();
    $companyId = $companyController->add($companyModel);
    if (!($companyId > 0)) {
        throw new ControllerException("Add failed.");
    }
    $newCompanyModel = $companyController->get($companyId);
    $companyRowView = new CompanyListView('html', null);
    $rows = $companyRowView->displayCompanyRow($newCompanyModel, 'list', $rowStyle);
} catch (ControllerException $e) {
    $companyRowView = new CompanyListView('html', null);
    $companyModel->setId($rowId);
    $rows = $companyRowView->displayCompanyRow($companyModel, 'add', $rowStyle, 'Add Company record failed. ' . $e->getMessage());
    $result = 'FAILED';
}
$result = array('result' => $result, 'rows' => $rows, 'newId' => $companyId);
echo json_encode($result) . PHP_EOL;
예제 #2
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$auth = new Auth();
if (!$auth->isAuthorized()) {
    $auth->forbidden();
    exit(0);
    // Should never get here but just in case...
}
$result = "OK";
$id = Tools::param('id');
$mode = Tools::param('mode');
$rowStyle = Tools::param('rowStyle');
$html = '';
$companyListView = new CompanyListView('html', null);
if ('add' == $mode) {
    $companyModel = new CompanyModel();
    $companyModel->setId($id);
    $htmlRows = $companyListView->displayCompanyRow($companyModel, $mode, $rowStyle);
} else {
    $companyController = new CompanyController();
    $companyModel = $companyController->get($id);
    $htmlRows = $companyListView->displayCompanyRow($companyModel, $mode, $rowStyle);
}
$result = array('result' => $result, 'rows' => $htmlRows);
echo json_encode($result) . PHP_EOL;
예제 #3
0
    public function displayContactRow($contactModel, $displayMode)
    {
        $id = $contactModel->getId();
        if ("add" === $displayMode) {
            $companyId = $companyName = $name = $email = $aphone = $bphone = $created = $updated = '';
        } else {
            $companyId = $contactModel->getContactCompanyId();
            $companyController = new CompanyController('read');
            if ($companyId > 0) {
                $companyModel = $companyController->get($companyId);
                $companyName = $companyModel->getCompanyName();
            } else {
                $companyName = '---';
            }
            $name = $contactModel->getContactName();
            $email = $contactModel->getContactEmail();
            $aphone = $contactModel->getContactPhone();
            $bphone = $contactModel->getContactAlternatePhone();
            $created = $contactModel->getCreated();
            $updated = $contactModel->getUpdated();
        }
        switch ($displayMode) {
            case 'add':
                $companyListView = new CompanyListView('html');
                $companyNames = $companyListView->getCompanyList("ix{$id}", $companyId);
                return <<<RETVAL
      <td><button type="button" id="SaveButtonix{$id}" onclick="saveAddContact( '{$id}' )">Save</button>
          <button type="button" id="CancelButtonix{$id}" onclick="deleteRow( 'ix{$id}' )">Cancel</button>
      </td>
      <td>{$companyNames}</td>
      <td><input type="text" id="nameix{$id}" value="{$name}"</td>
      <td><input type="email" id="emailix{$id}" value="{$email}"</td>
      <td><input type="text" id="phoneix{$id}" value="{$aphone}"</td>
      <td><input type="text" id="alternatePhoneix{$id}" value="{$bphone}" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>

RETVAL;
            case 'update':
                $companyListView = new CompanyListView('html');
                $companyNames = $companyListView->getCompanyList("{$id}", $companyId);
                return <<<RETVAL
      <td><button type="button" id="SaveButton{$id}" onclick="saveAddContact( '{$id}' )">Save</button>
          <button type="button" id="CancelButton{$id}" onclick="deleteRow( '{$id}' )">Cancel</button>
      </td>
      <td>{$companyNames}</td>
      <td><input type="text" id="name{$id}" value="{$name}"</td>
      <td><input type="email" id="email{$id}" value="{$email}"</td>
      <td><input type="text" id="phone{$id}" value="{$aphone}"</td>
      <td><input type="text" id="alternatePhone{$id}" value="{$bphone}" /></td>
      <td>{$created}</td>
      <td>{$updated}</td>
                
RETVAL;
            case 'delete':
                return <<<RETVAL
      <td><button type="button" id="DeleteButton{$id}" onclick="doDeleteContact( '{$id}' )">Confirm Delete</button>
          <button type="button" id="CancelButton{$id}" onclick="cancelUpdateContactRow( '{$id}' )">Cancel</button>
      </td>
      <td>{$companyName}</td>
      <td>{$name}</td>
      <td>{$email}</td>
      <td>{$aphone}</td>
      <td>{$bphone}</td>
      <td>{$created}</td>
      <td>{$updated}</td>
                
RETVAL;
                break;
            case 'list':
                return <<<RETVAL
      <td><button type="button" id="UpdateButton{$id}" onclick="updateContact( '{$id}' )">Update</button>
          <button type="button" id="DeleteButton{$id}" onclick="deleteContact( '{$id}' )">Delete</button>
      </td>
      <td>{$companyName}</td>
      <td>{$name}</td>
      <td>{$email}</td>
      <td>{$aphone}</td>
      <td>{$bphone}</td>
      <td>{$created}</td>
      <td>{$updated}</td>
                
RETVAL;
            default:
                throw new ViewException('Undefined display mode');
        }
    }
예제 #4
0
<?php

require_once "Libs/autoload.php";
$auth = new Auth();
if (!$auth->isAuthorized()) {
    $auth->forbidden();
    exit(0);
    // Should never get here but just in case...
}
$id = Tools::param('id');
$result = 'OK';
$rows = array("", "");
try {
    $companyModel = new CompanyModel();
    $companyModel->setId($id);
    $companyController = new CompanyController();
    $companyController->delete($companyModel);
} catch (ControllerException $e) {
    $result = "Delete failed. " . $e->getMessage();
    $companyController = new CompanyController();
    $companyModel = $companyController->get($id);
    $companyListView = new CompanyListView();
    $rows = $companyListView->displayCompanyRow($companyModel, 'list', 'add', $result);
}
echo json_encode(array('result' => $result, 'rows' => $rows)) . PHP_EOL;
예제 #5
0
파일: companies.php 프로젝트: kbcmdba/pjs2
/**
 * phpjobseeker
 *
 * Copyright (C) 2009, 2015 Kevin Benton - kbenton at bentonfam dot org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once 'Libs/autoload.php';
$config = new Config();
$page = new PJSWebPage($config->getTitle() . " - Companies");
$body = "<h2>Companies</h2>\n";
$companyController = new CompanyController('read');
$companyModelList = $companyController->getAll();
$companyListView = new CompanyListView('html', $companyModelList);
$body .= $companyListView->getView();
$page->setBody($body);
$page->displayPage();
예제 #6
0
$id = Tools::param('id');
$result = 'OK';
$companyId = '';
$agencyCompanyId = Tools::param('agencyCompanyId');
$companyName = Tools::param('companyName');
$companyAddress1 = Tools::param('companyAddress1');
$companyAddress2 = Tools::param('companyAddress2');
$companyCity = Tools::param('companyCity');
$companyState = Tools::param('companyState');
$companyZip = Tools::param('companyZip');
$companyPhone = Tools::param('companyPhone');
$companyUrl = Tools::param('companyUrl');
$rowStyle = Tools::param('rowStyle');
$rowId = Tools::param('rowId');
$result = 'OK';
$clv = new CompanyListView('html', null);
try {
    $companyController = new CompanyController();
    $companyModel = $companyController->get($id);
    $companyModel->setAgencyCompanyId($agencyCompanyId);
    $companyModel->setCompanyName($companyName);
    $companyModel->setCompanyAddress1($companyAddress1);
    $companyModel->setCompanyAddress2($companyAddress2);
    $companyModel->setCompanyCity($companyCity);
    $companyModel->setCompanyState($companyState);
    $companyModel->setCompanyZip($companyZip);
    $companyModel->setCompanyPhone($companyPhone);
    $companyModel->setCompanyUrl($companyUrl);
    $result = $companyController->update($companyModel);
    if (!($result > 0)) {
        throw new ControllerException("Update failed.");