public static function addCompany($company_data, $client_setup = false)
 {
     if (isset($branch_data)) {
         //Checking the required params.
         foreach (self::$REQUIRED_PARAMS as $param) {
             if (!isset($branch_data[$param]) || $branch_data[$param] == '') {
                 self::$is_missing_param = true;
                 break;
             }
         }
         if (!$this->is_missing_param) {
             $branch_data['added_by'] = SessionCache::get('user_id');
             $company_dao = DAOFactory::getDAO('CompanyDAO');
             $ret = $company_dao->insertCompanyBranch($branch_data);
             return $ret;
         } else {
             //$this->sendJsonResponse(0,$msg);
         }
     }
 }
 public function clientSetup()
 {
     $this->disableCaching();
     $this->setViewTemplate('new_client_setup.tpl');
     if (isset($_POST['Submit']) && $_POST['Submit'] == 'Submit') {
         if (isset($_POST['company'])) {
             $company_id = CompanyController::addCompany($_POST['company'], 1);
             if (isset($_POST['client']) && $company_id) {
                 $_POST['client']['company_branch_id'] = $company_id;
                 $client_id = $this->addClient($_POST['client']);
                 if (isset($_POST['package']) && $client_id) {
                     //here have to do work for packages, either selection of
                     //package of creation of package.
                     $package_id = PackageController::makePackage();
                     if (isset($_POST['severity']) && $package_id) {
                         SeverityGridController::addSeverity($_POST['severity']);
                     } else {
                         // error response
                     }
                 } else {
                     // error response
                 }
             } else {
                 // error response
             }
         } else {
             //error_response
         }
         //Add Client into database
         $client_data = $_POST['client'];
         if (!isset($client_data['company_branch_id']) || $client_data['company_branch_id'] == '') {
             $client_data['company_branch_id'] = $company_id;
         }
     }
     return $this->generateView();
 }
Example #3
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;
Example #4
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;
 private function updateParameters($model)
 {
     if ($model->reportparameters !== null && count($model->reportparameters) > 0) {
         $repParams = $model->reportparameters;
         foreach ($repParams as $n => $repParam) {
             //see if there is new data to be added..
             if ($_POST['ReportParameters'][$n]) {
                 $repParam->attributes = $_POST['ReportParameters'][$n];
                 //this is a bug in yii that requires me to do the next row
                 $repParam->defaultValue = $_POST['ReportParameters'][$n]['defaultValue'];
                 $repParam->isDefaultPhp = $_POST['ReportParameters'][$n]['isDefaultPhp'];
                 $repParam->phpSecondaryInfo = $_POST['ReportParameters'][$n]['phpSecondaryInfo'];
                 $repParam->dataType = $_POST['ReportParameters'][$n]['dataType'];
                 //echo  $repParam->dataType . ' ' . $_POST['ReportParameters'][$n]['dataType'];
                 //die();
                 $repParam->save();
             }
         }
     }
     if ($model->rows !== null && count($model->rows) > 0) {
         $repRows = $model->rows;
         foreach ($repRows as $n => $repRow) {
             $repRow->attributes = $_POST['ReportRows'][$n];
             $repRow->save();
         }
     }
     if ($model->groups !== null && count($model->groups) > 0) {
         $repGroups = $model->groups;
         foreach ($repGroups as $n => $repGroup) {
             //see if there is new data to be added..
             if ($_POST['ReportGroups'][$n]) {
                 $repGroup->attributes = $_POST['ReportGroups'][$n];
                 $repGroup->save();
                 if ($repGroup->fields !== null && count($repGroup->fields) > 0) {
                     $repGroupFields = $repGroup->fields;
                     foreach ($repGroupFields as $m => $repGroupField) {
                         //see if there is new data to be added..
                         $repGroupField->attributes = $_POST['ReportGroupFields'][$n][$m];
                         //$repGroupField->sortOrder=$_POST['ReportGroupFields'][$n]['sortOrder'][$m];
                         //$repGroupField->fieldName=$_POST['ReportGroupFields'][$n]['fieldName'][$m];
                         //$repGroupField->fieldWidth=$_POST['ReportGroupFields'][$n]['fieldWidth'][$m];
                         //$repGroupField->row=$_POST['ReportGroupFields'][$n]['row'][$m];
                         //$repGroupField->isDate=$_POST['ReportGroupFields'][$n]['isDate'][$m];
                         //$repGroupField->isDecimal=$_POST['ReportGroupFields'][$n]['isDecimal'][$m];
                         //$repGroupField->fieldCalc=$_POST['ReportGroupFields'][$n]['fieldCalc'][$m];
                         $repGroupField->save();
                     }
                 }
             }
         }
     }
     if (isset($_POST['AddRow'])) {
         $rowparam = new ReportParameters();
         $rowparam->reportId = $model->id;
         $rowparam->save();
     }
     if (isset($_POST['deleterow'])) {
         $deletes = $_POST['deleterow'];
         //there is only one item in this array, but I don't know
         //any other way to get at it without doing this..
         foreach ($deletes as $key => $transrow) {
             $model->reportparameters[$key]->delete();
             break;
         }
     }
     if (isset($_POST['AddReportRow'])) {
         $rowparam = new ReportRows();
         $rowparam->reportId = $model->id;
         $rowparam->save();
     }
     if (isset($_POST['AddGroupRow'])) {
         $rowparam = new ReportGroups();
         $rowparam->reportId = $model->id;
         $rowparam->save();
     }
     if (isset($_POST['deletereportrow'])) {
         $deletes = $_POST['deletereportrow'];
         //there is only one item in this array, but I don't know
         //any other way to get at it without doing this..
         foreach ($deletes as $key => $transrow) {
             $model->rows[$key]->delete();
             break;
         }
     }
     if (isset($_POST['deletegrouprow'])) {
         $deletes = $_POST['deletegrouprow'];
         //there is only one item in this array, but I don't know
         //any other way to get at it without doing this..
         foreach ($deletes as $key => $transrow) {
             $groupFields = $model->groups[$key]->fields;
             $model->groups[$key]->delete();
             break;
         }
     }
     if (isset($_POST['AddGroupFieldRow'])) {
         $adds = $_POST['AddGroupFieldRow'];
         //there is only one item in this array, but I don't know
         //any other way to get at it without doing this..
         foreach ($adds as $key => $transrow) {
             $rowGroup = new ReportGroupFields();
             $rowGroup->reportGroupId = $model->groups[$key]->id;
             $rowGroup->save();
             break;
         }
     }
     if (isset($_POST['deletegroupfieldrow'])) {
         //print_r($_POST);echo "<br><br><br>";
         //print_r($_POST['deletegroupfieldrow']);
         //die();
         $deletes = $_POST['deletegroupfieldrow'];
         //there is only one item in this array, but I don't know
         //any other way to get at it without doing this..
         foreach ($deletes as $key => $transrow) {
             $deletes2 = $_POST['deletegroupfieldrow'][$key];
             foreach ($deletes2 as $key2 => $transrow2) {
                 $model->groups[$key]->fields[$key2]->delete();
                 break;
             }
             break;
         }
     }
     if (isset($_POST['Export'])) {
         $dom = new DomDocument();
         $dom->encoding = 'utf-8';
         $root = $dom->createElement("lazy8webportreport");
         $root->setAttribute("version", "1.00");
         $this->ExportOneReport($model, $dom, $root);
         $dom->appendChild($root);
         $dom->formatOutput = true;
         $thefile = $dom->saveXML();
         // set headers
         include 'CompanyController.php';
         header("Pragma: no-cache");
         header("Expires: 0");
         header("Content-Description: File Transfer");
         header("Content-Type: text/xml");
         header("Content-Disposition: attachment; filename=\"lazy8webExport.Report." . CompanyController::replace_bad_filename_chars($model->name) . "." . date('Y-m-d_H.i.s') . ".xml\"");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . strlen($thefile));
         //flush();
         print $thefile;
         return;
         //we may not send any more to the screen or it will mess up the file we just sent!
     }
 }
 public function actionExportall()
 {
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8webExport.Templates." . CompanyController::replace_bad_filename_chars(Yii::app()->user->getState('selectedCompanyName')) . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     $writer = new XMLWriter();
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webtemplates');
     $writer->writeAttribute('version', '1.00');
     Template::exportAllTemplates($writer, Yii::app()->user->getState('selectedCompanyId'));
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
 }
Example #7
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');
        }
    }
                                        </td>
                                  </tr>
                                    
                                    <tr>
                                   	  <td>
                                    		<form method="post" action="../View/Companies/SearchCompanies.php">
                                      	
                                      	<input type="text" name="value" />
                                        <input type="submit" name="search" value="بحث"/>
                                      </td>
                                    </tr>
                                    
                                  <tr>
                                    	<td height="150" valign="top" align="center">
                                        	<?php 
$AllCompanies = new CompanyController();
if (isset($_POST['value']) && !$_POST['value'] == "") {
    $AllCompanies->invoke($_POST['value']);
}
?>
                                    </td>
                                  </tr>
                                </table>
                            </td>
                            
                            <td style="width:25%;" valign="top">
                            <?php 
$loginCtrl->LoggedOrNot();
?>
                            </td>
                        </tr>
 /**
  * @api {post} /groups/users/:idUser/add Add New Group by Manager
  * @apiName Add New Group by Manager
  * @apiGroup Group
  * @apiDescription Create a child group of the company the specified user is in.
  *                 <p>The user must be admin/owner of his company group.</p>
  *                 <p>The user will be the owner of the new group.</p>
  * @apiHeader (Header) {String} X_Authorization Authorization value.
  * @apiParam  (url Parameter) {Number} idUser User's unique ID.
  * @apiParam  (Parameter) {String} name New group name. <b>Unique</b>
  * @apiParam  (Parameter) {String} description New group description.
  *
  * @apiError 400 Input Invalid. This will happen if the param is missing or not in the valid format.
  * @apiError 404 Not found. This will happen if the role id/user id/group id is not in our system.
  * @apiError 403 Permission denied. 
  * @apiError 401 Not authorized. This will happen if the header value is not attached.
  * @apiError 409 Group name already exists. 
  *
  * @apiSuccess 200 
  */
 public static function add($idUser)
 {
     $app = \Slim\Slim::getInstance();
     $data = $app->request->post();
     //validate input
     $validata = $app->validata;
     $validator = $validata::key('name', $validata::stringType()->notEmpty())->key('description', $validata::stringType()->notEmpty());
     if (!$validator->validate((array) $data)) {
         $app->halt(400, json_encode("Input Invalid"));
     }
     $group = Group::where('name', $data['name'])->first();
     if ($group) {
         $app->halt(409, json_encode("Group name already exists"));
     }
     $companies = User::find($idUser)->companies;
     $parent_group = CompanyController::getCompanyGroup($companies[0]->id);
     if (!$parent_group) {
         $app->halt(404, json_encode("Parent group does not exist"));
     }
     if ($companies) {
         $role = self::getRole($parent_group->id, $idUser);
         if ($role->id < 3) {
             $app->halt("403", json_encode("Permission denied"));
         }
         $group = new Group();
         $group->company_id = $companies[0]->id;
         $group->is_exclusive = 0;
         $group->parent_id = $parent_group->id;
         $group->name = $data['name'];
         $group->description = $data['description'];
         $group->access_code = CompanyController::generateRandomString(8);
         $group->save();
         if ($group->id) {
             $group->members()->attach($idUser, array('role_id' => 3));
         }
     }
 }
}
echo '<a href="SearchCompanies.php">بحث</a>';
?>
                                        </td>
                                  </tr>
                                    
                                    <tr>
                                   	  <td>
                                    		الشركات الحالية
                                      </td>
                                    </tr>
                                    
                                  <tr>
                                    	<td height="150" valign="top" align="center">
                                        	<?php 
$AllCompanies = new CompanyController();
$AllCompanies->invoke("");
?>
                                    </td>
                                  </tr>
                                </table>
                            </td>
                            
                            <td style="width:25%;" valign="top">
                            <?php 
$loginCtrl->LoggedOrNot();
?>
                            </td>
                        </tr>
                    </table>
                </td>
Example #11
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;
    }
Example #12
0
<?php

$app->group('/company', function () use($app) {
    $companyController = new CompanyController();
    $app->get('/list/json', function () use($app, $companyController) {
        header('Access-Control-Allow-Origin: *');
        $companys = $companyController->listAll();
        echo json_encode($companys);
    });
    $app->get('/:id/json', function ($id) use($app, $companyController) {
        header('Access-Control-Allow-Origin: *');
        $company = $companyController->getById($id);
        $app->conn = null;
        echo json_encode($company);
    });
    $app->get('/list', function () use($app, $companyController) {
        $list = $companyController->listAll();
        $app->render("company/companyListView.php", array("list" => $list));
    });
    $app->get('/new', function () use($app, $companyController) {
        $app->render("company/companyNewView.php", array());
    });
    $app->post('/new', function () use($app, $companyController) {
        $post = $app->request->params();
        $name = @$post['name'];
        $description = @$post['description'];
        $logo = @$_FILES['logo'];
        $link = @$post['link'];
        $posX = @$post['pos_x'];
        $posY = @$post['pos_y'];
        if (!empty($name) && !empty($description) && !empty($logo) && !empty($link) && !empty($posX) && !empty($posY)) {
 /**
  * @return array Errors Export Account information
  */
 public static function ExportAccounts()
 {
     $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId'));
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8web.accounts." . CompanyController::replace_bad_filename_chars($comp->name) . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     //header("Content-Length: " );
     $writer = new XMLWriter();
     // Output directly to the user
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webportaccount');
     $writer->writeAttribute('version', '1.00');
     $accountTypes = AccountType::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId')));
     foreach ($accountTypes as $accountType) {
         $writer->startElement('accounttype');
         $writer->writeAttribute("code", $accountType->code);
         $writer->writeAttribute("name", $accountType->name);
         $writer->writeAttribute("sortorder", $accountType->sortOrder);
         $writer->writeAttribute("isinbalance", $accountType->isInBalance);
         $accounts = Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId') . ' AND accountTypeId=' . $accountType->id));
         foreach ($accounts as $account) {
             $allAccounts[$account->id] = $account->code;
             $writer->startElement('account');
             $writer->writeAttribute("code", $account->code);
             $writer->writeAttribute("name", $account->name);
             $writer->writeAttribute("email", $account->email);
             $writer->writeAttribute("balance_threshold", $account->balance_threshold);
             $writer->writeAttribute("days", $account->days);
             $writer->writeAttribute("report_id", $account->report_id);
             $writer->endElement();
         }
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
     return;
     //we may not send any more to the screen or it will mess up the file we just sent!
 }
 private function exportCompany($companyId = null)
 {
     $compName = "AllCompanies";
     if ($companyId != null) {
         $compName = CompanyController::replace_bad_filename_chars(Company::model()->findbyPk($companyId)->name);
     }
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8webExport.Company." . $compName . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     //safari can't deal with this header length zero
     //		header("Content-Length: " );
     $writer = new XMLWriter();
     // Output directly to the user
     //dirname(__FILE__).DIRECTORY_SEPARATOR.'../..'.'/assets/upload.sql'
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webport');
     $writer->writeAttribute('version', '1.00');
     $companies = array();
     if (isset($companyId)) {
         $companies[] = Company::model()->findbyPk($companyId);
     } else {
         $companies = Company::model()->findAll(array('order' => 'code'));
     }
     foreach ($companies as $company) {
         ChangeLog::addLog('OTHER', 'Company', 'Exported company ' . $company->toString());
         $writer->startElement('company');
         $writer->writeAttribute("code", $company->code);
         $writer->writeAttribute("name", $company->name);
         $writer->writeAttribute("lastAbsTransNum", $company->lastAbsTransNum);
         $allAccounts = array();
         $accountTypes = AccountType::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         foreach ($accountTypes as $accountType) {
             $writer->startElement('accounttype');
             $writer->writeAttribute("code", $accountType->code);
             $writer->writeAttribute("name", $accountType->name);
             $writer->writeAttribute("sortorder", $accountType->sortOrder);
             $writer->writeAttribute("isinbalance", $accountType->isInBalance);
             $accounts = Account::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND accountTypeId=' . $accountType->id, 'order' => 'code'));
             foreach ($accounts as $account) {
                 $allAccounts[$account->id] = $account->code;
                 $writer->startElement('account');
                 $writer->writeAttribute("code", $account->code);
                 $writer->writeAttribute("name", $account->name);
                 $writer->endElement();
             }
             $writer->endElement();
         }
         $customers = Customer::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         $allCustomers = array();
         foreach ($customers as $customer) {
             $writer->startElement('customer');
             $allCustomers[$customer->id] = $customer->code;
             $writer->writeAttribute("code", $customer->code);
             $writer->writeAttribute("name", $customer->name);
             $writer->writeAttribute("desc", $customer->desc);
             if (isset($allAccounts[$customer->accountId])) {
                 $writer->writeAttribute("accountcode", $allAccounts[$customer->accountId]);
             } else {
                 $writer->writeAttribute("accountcode", 0);
             }
             $writer->endElement();
         }
         $periods = Period::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'dateStart'));
         foreach ($periods as $period) {
             $writer->startElement('period');
             $writer->writeAttribute("datestart", $period->dateStart);
             $writer->writeAttribute("dateend", $period->dateEnd);
             $writer->writeAttribute("lastperiodtransnum", $period->lastPeriodTransNum);
             $transactions = Trans::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND periodId=' . $period->id, 'order' => 'companyNum'));
             foreach ($transactions as $transaction) {
                 $writer->startElement('transaction');
                 $writer->writeAttribute("code", $transaction->companyNum);
                 $writer->writeAttribute("periodnum", $transaction->periodNum);
                 $writer->writeAttribute("regdate", $transaction->regDate);
                 $writer->writeAttribute("invdate", $transaction->invDate);
                 $writer->writeAttribute("notes", $transaction->notes);
                 $writer->writeAttribute("fileinfo", $transaction->fileInfo);
                 $transrows = TransRow::model()->findAll(array('condition' => 'transId=' . $transaction->id, 'order' => 'amount DESC'));
                 foreach ($transrows as $transrow) {
                     $writer->startElement('amount');
                     $writer->writeAttribute("accountcode", isset($allAccounts[$transrow->accountId]) ? $allAccounts[$transrow->accountId] : 0);
                     $writer->writeAttribute("customercode", isset($allCustomers[$transrow->customerId]) ? $allCustomers[$transrow->customerId] : 0);
                     $writer->writeAttribute("notes", $transrow->notes);
                     $writer->writeAttribute("amount", $transrow->amount);
                     $writer->endElement();
                 }
                 $writer->endElement();
             }
             $writer->endElement();
         }
         yii::app()->onExport(new Lazy8Event(array('exportobject' => 'Company', 'writer' => $writer), $company->id));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
     return;
     //we may not send any more to the screen or it will mess up the file we just sent!
 }
Example #15
0
 /**
  * Get Agency SELECT list
  * 
  * @param string $id Field ID
  * @param integer $value Selected Value
  * @return string
  */
 public function getAgencyList($id, $value)
 {
     $retVal = "<select id=\"agencyCompanyId{$id}\" >\n  <option value=\"\">---</option>";
     $companyController = new CompanyController();
     $agencies = $companyController->getAll();
     foreach ($agencies as $agency) {
         $selected = $agency->getId() === $value ? "selected=\"selected\"" : "";
         $aname = $agency->getCompanyName();
         $aid = $agency->getId();
         $retVal .= "  <option value=\"{$aid}\" {$selected}>{$aname}</option>\n";
     }
     $retVal .= "</select>\n";
     return $retVal;
 }
Example #16
0
/**
 * 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();
Example #17
0
$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.");
    }
    $rows = $clv->displayCompanyRow($companyModel, 'list', $rowStyle);