$auth->forbidden();
    exit(0);
    // Should never get here but just in case...
}
$statusValue = Tools::post('statusValue');
$style = Tools::post('style');
$isActive = Tools::post('isActive');
$sortKey = Tools::post('sortKey');
$result = 'OK';
$applicationStatusId = '';
$newApplicationStatusModel = null;
try {
    $applicationStatusModel = new ApplicationStatusModel();
    $applicationStatusModel->setStatusValue($statusValue);
    $applicationStatusModel->setStyle($style);
    $applicationStatusModel->setIsActive($isActive);
    $applicationStatusModel->setSortKey($sortKey);
    $applicationStatusController = new ApplicationStatusController();
    $applicationStatusId = $applicationStatusController->add($applicationStatusModel);
    if (!($applicationStatusId > 0)) {
        throw new ControllerException("Add failed.");
    }
    $newApplicationStatusModel = $applicationStatusController->get($applicationStatusId);
    $applicationStatusRowView = new ApplicationStatusListView();
    $row = $applicationStatusRowView->displayApplicationStatusRow($newApplicationStatusModel, 'list');
} catch (ControllerException $e) {
    $applicationStatusRowView = new ApplicationStatusListView('html', null);
    $row = $applicationStatusRowView->displayApplicationStatusRow($newApplicationStatusModel, 'list', 'Add Application Status record failed. ' . $e->getMessage());
}
$result = array('result' => $result, 'row' => $row, 'newId' => $applicationStatusId);
echo json_encode($result) . PHP_EOL;
 * 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";
$auth = new Auth();
if (!$auth->isAuthorized()) {
    $auth->forbidden();
    exit(0);
    // Should never get here but just in case...
}
$result = "OK";
$id = Tools::post('id');
$mode = Tools::post('mode');
$html = '';
$applicationStatusListView = new ApplicationStatusListView('html', null);
if ('add' == $mode) {
    $applicationStatusModel = new ApplicationStatusModel();
    $applicationStatusModel->setId($id);
    $html = $applicationStatusListView->displayApplicationStatusRow($applicationStatusModel, $mode);
} else {
    $applicationStatusController = new ApplicationStatusController();
    $applicationStatusModel = $applicationStatusController->get($id);
    $html = $applicationStatusListView->displayApplicationStatusRow($applicationStatusModel, $mode);
}
$result = array('result' => $result, 'row' => $html);
echo json_encode($result) . PHP_EOL;
Exemple #3
0
    /**
     * Return the HTML view
     *
     * @return string
     */
    private function _getHtmlView()
    {
        $body = <<<'HTML'
<a href="addJob.php">Add a new job</a><br />
<table border="1" cellspacing="0" cellpadding="2">
  <caption>Current Jobs</caption>
  <tr>
    <th>Actions</th>
    <th>Urgency</th>
    <th>Title</th>
    <th>Location</th>
    <th>Company</th>
    <th>Contact</th>
    <th>Status</th>
    <th>Next Action</th>
    <th>Next Action Due</th>
    <th>Link</th>
    <th>Created</th>
    <th>Updated</th>
  </tr>
HTML;
        foreach ($this->getJobModels() as $jobModel) {
            $id = $jobModel->getId();
            $primaryContactId = $jobModel->getPrimaryContactId();
            $companyId = $jobModel->getCompanyId();
            $applicationStatusId = $jobModel->getApplicationStatusId();
            $lastStatusChange = $jobModel->getLastStatusChange();
            $urgency = $jobModel->getUrgency();
            $created = $jobModel->getCreated();
            $updated = $jobModel->getUpdated();
            $nextActionDue = $jobModel->getNextActionDue();
            $nextAction = $jobModel->getNextAction();
            $positionTitle = $jobModel->getPositionTitle();
            $location = $jobModel->getLocation();
            $url = $jobModel->getUrl();
            if ($primaryContactId >= 1) {
                $contactController = new ContactController('read');
                $contactModel = $contactController->get($primaryContactId);
                $contactName = $contactModel->getContactName();
            }
            if ($companyId >= 1) {
                $companyController = new CompanyController('read');
                $companyModel = $companyController->get($companyId);
                $companyName = $companyModel->getCompanyName();
            } else {
                $companyName = '';
            }
            if ($applicationStatusId >= 1) {
                $applicationStatusController = new ApplicationStatusController('read');
                $applicationStatusModel = $applicationStatusController->get($applicationStatusId);
                $applicationStatusValue = $applicationStatusModel->getStatusValue();
                $applicationStatusStyle = $applicationStatusModel->getStyle();
            } else {
                $applicationStatusValue = '';
                $applicationStatusStyle = '';
            }
            $body .= <<<HTML
  <tr>
    <td>
        <a href="editJob.php?id={$id}">Edit</a>
      | <a href="deleteJob.php?id={$id}">Delete</a>
    </td>
    <td>{$urgency}</td>
    <td>{$positionTitle}</td>
    <td>{$location}</td>
    <td>{$companyName}</td>
    <td>{$contactName}</td>
    <td style="{$applicationStatusStyle}">{$applicationStatusValue}</td>
    <td>{$nextAction}</td>
    <td>{$nextActionDue}</td>
    <td><a href="{$url}">{$url}</a></td>
    <td>{$created}</td>
    <td>{$updated}</td>
  </tr>
HTML;
        }
        $body .= '</table>';
        return $body;
    }