Exemplo n.º 1
0
 public function _new()
 {
     $flash = Flash::Instance();
     parent::_new();
     $gl_params = $this->_uses[$this->modeltype];
     $unassigned = $gl_params->unassignedParams();
     if (count($unassigned) > 0) {
         $this->view->set('unassigned', $unassigned);
     } elseif (count($unassigned) == 0 && $this->_data['action'] == 'new') {
         $flash->addMessage('All parameters have been assigned');
         sendTo($this->name, 'index', $this->_modules);
     } elseif ($this->_data['action'] == 'new') {
         $flash->addError('Error getting Parameter List');
         sendback();
     }
     if (isset($_POST[$this->modeltype]['paramdesc'])) {
         $this->selectlist($_POST[$this->modeltype]['paramdesc']);
     } elseif ($gl_params->isLoaded()) {
         $this->selectlist($gl_params->paramdesc);
         $this->view->set('selected', $gl_params->paramvalue_id);
     } else {
         $this->selectlist(key($unassigned));
     }
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['view'] = array('tag' => 'View Parameters', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index')));
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Exemplo n.º 2
0
 public function view()
 {
     if (!$this->loadData()) {
         sendback();
     }
     $ledgercategory = $this->_uses[$this->modeltype];
     $idfield = $ledgercategory->idField;
     $id = $ledgercategory->{$idfield};
     // Check if Ledger Category is used by Ledger Accounts
     $ledgeraccount = new LedgerCategory('ledger_category_accounts');
     $ledgeraccount->idField = 'company_id';
     $ledgeraccount->identifierField = 'name';
     $cc = new ConstraintChain();
     $cc->add(new Constraint('category_id', '=', $ledgercategory->category_id));
     $ledgeraccounts = $ledgeraccount->getAll($cc);
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['all'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'), 'tag' => 'view_ledger_categories');
     $sidebarlist['new'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'), 'tag' => 'new_ledger_category');
     if (count($ledgeraccounts) == 0) {
         $sidebarlist['edit'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', $idfield => $ledgercategory->{$idfield}), 'tag' => 'edit_ledger_category');
         $sidebarlist['delete'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', $idfield => $ledgercategory->{$idfield}), 'tag' => 'delete_ledger_category');
     }
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('model', $ledgercategory);
     $this->view->set('count', count($ledgeraccounts));
 }
Exemplo n.º 3
0
 public function _new()
 {
     $flash = Flash::Instance();
     $errors = array();
     $glaccounts = new GLAccount();
     if ($glaccounts->getCount() == 0) {
         $errors[] = 'No GL Accounts defined';
     }
     $glcentres = new GLCentre();
     if ($glcentres->getCount() == 0) {
         $errors[] = 'No GL Centres defined';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendback();
     }
     parent::_new();
     $currency = $this->_uses[$this->modeltype];
     $glaccounts = $glaccounts->getAll();
     if (isset($_POST[$this->modeltype]['writeoff_glaccount_id'])) {
         $default_glaccount_id = $_POST[$this->modeltype]['writeoff_glaccount_id'];
     } elseif (isset($this->_data['writeoff_glaccount_id'])) {
         $default_glaccount_id = $this->_data['writeoff_glaccount_id'];
     } elseif ($currency->isLoaded()) {
         $default_glaccount_id = $currency->writeoff_glaccount_id;
     } else {
         $default_glaccount_id = key($glaccounts);
     }
     $this->view->set('glcentres', $this->getCentres($default_glaccount_id));
 }
Exemplo n.º 4
0
 public function _new()
 {
     $flash = Flash::Instance();
     $errors = array();
     $currency = new Currency();
     if ($currency->getCount() == 0) {
         $errors[] = 'No Currencies defined';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendback();
     }
     parent::_new();
 }
Exemplo n.º 5
0
 public function edit()
 {
     $flash = Flash::Instance();
     parent::edit();
     $modulecomponent = $this->_uses[$this->modeltype];
     $this->addSidebar($modulecomponent);
     switch ($modulecomponent->type) {
         case 'C':
             break;
         case 'M':
             $model = new $modulecomponent->name();
             $fields = $model->getFields();
             $current_defaults = array();
             foreach ($modulecomponent->module_defaults as $default) {
                 $current_defaults[$default->field_name] = $default->id;
             }
             foreach ($fields as $field) {
                 if (isset($current_defaults[$field->name])) {
                     $field->id = $current_defaults[$field->name];
                 }
             }
             $this->view->set('model_class', $model);
             $this->view->set('models', array($modulecomponent->name => $model));
             $this->view->set('fields', $fields);
             $this->view->set('type', 'display');
             if (is_null($modulecomponent->title)) {
                 $modulecomponent->title = $model->getTitle();
             }
             if ($model instanceof DataObject) {
                 $this->view->set('internal_type', 'DataObject');
             } elseif ($model instanceof DataObjectCollection) {
                 $this->view->set('internal_type', 'DataObjectCollection');
             }
             $this->view->set('version', $model->version());
             break;
         default:
             $flash->addWarning('Edit of ' . $modulecomponent->getEnum('type', $modulecomponent->type) . ' not allowed');
             sendback();
     }
     $this->view->set('ModuleComponent', $modulecomponent);
 }
Exemplo n.º 6
0
 public function _new()
 {
     $flash = Flash::Instance();
     $errors = array();
     $glaccounts = DataObjectFactory::Factory('GLAccount');
     if ($glaccounts->getCount() == 0) {
         $errors[] = 'No GL Accounts defined';
     }
     $glcentres = DataObjectFactory::Factory('GLCentre');
     if ($glcentres->getCount() == 0) {
         $errors[] = 'No GL Centres defined';
     }
     $currency = DataObjectFactory::Factory('Currency');
     if ($currency->getCount() == 0) {
         $errors[] = 'No Currencies defined';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendback();
     }
     parent::_new();
     $cbaccount = $this->_uses[$this->modeltype];
     if (!$cbaccount->isLoaded()) {
         $params = DataObjectFactory::Factory('GLParams');
         $currency = $params->base_currency();
         $this->view->set('currency', $currency);
     }
     $glaccounts = $glaccounts->getAll();
     $this->view->set('glaccounts', $glaccounts);
     if (isset($_POST[$this->modeltype]['glaccount_id'])) {
         $default_glaccount_id = $_POST[$this->modeltype]['glaccount_id'];
     } elseif ($cbaccount->isLoaded()) {
         $default_glaccount_id = $cbaccount->glaccount_id;
     } else {
         $default_glaccount_id = key($glaccounts);
     }
     $this->view->set('glcentres', $this->getCentres($default_glaccount_id));
 }
Exemplo n.º 7
0
    $body .= '<h2>Echelon Admin User Information</h2>';
    $body .= 'This is the admin user login informtion.<br />';
    $body .= 'Username: <b>admin</b><br />';
    $body .= 'Password: <b>' . $user_pw . "</b><br />";
    $body .= 'If you have not already, please entirely remove the install folder from Echelon (/echelon/install/).<br />';
    $body .= 'Thank you for downloading and installing Echelon, <br />';
    $body .= 'The B3 Dev. Team';
    $body .= '</body></html>';
    $headers = "From: echelon@" . $_SERVER['HTTP_HOST'] . "\r\n";
    $headers .= "Reply-To: " . $email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $subject = "Echelon Admin User Setup";
    // send email
    if (!mail($email, $subject, $body, $headers)) {
        sendback('There was a problem sending the user login information email.');
    }
    ## Done ##
    send('index.php?t=done');
    // send to a thankyou done page that explains what next
}
// end install
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Echelon Install Package</title>
	
		<link href="../css/style.css" rel="stylesheet" media="screen" type="text/css" />
Exemplo n.º 8
0
 public function save_allocation()
 {
     $db = DB::Instance();
     $db->StartTrans();
     $total = 0;
     $base_total = 0;
     $flash = Flash::Instance();
     $errors = array();
     if (!isset($this->_data['transactions'])) {
         $flash->addError('You must select at least one transaction');
     } else {
         $transactions = $this->_data['transactions'];
         foreach ($transactions as $id => $on) {
             $trans = DataObjectFactory::Factory('ELTransaction');
             $trans->load($id);
             $total = bcadd($total, $trans->os_value);
             $base_total = bcadd($base_total, $trans->base_os_value);
             $trans_store[] = $trans;
         }
         if ($total == 0) {
             foreach ($trans_store as $transaction) {
                 $transaction->status = 'P';
                 $transaction->os_value = 0;
                 $transaction->twin_os_value = 0;
                 $transaction->base_os_value = 0;
                 $transaction->for_payment = 'f';
                 if ($transaction->saveForPayment($errors) === false) {
                     $flash->addErrors($errors);
                     $flash->addError('Error saving transaction');
                     $db->Failtrans();
                     $db->CompleteTrans();
                     sendback();
                 }
                 if ($transaction->transaction_type == 'E') {
                     $expense = DataObjectFactory::Factory('Expense');
                     $expense->loadBy('expense_number', $transaction->our_reference);
                     if (!$expense->isLoaded() || !$expense->update($expense->{$expense->idField}, 'status', $expense->statusPaid())) {
                         $flash->addError('Error updating Expenses');
                         $db->Failtrans();
                         $db->CompleteTrans();
                         sendback();
                     }
                 }
             }
             if ($base_total != 0) {
                 $data = array();
                 $data['docref'] = $this->_data['employee_id'];
                 $data['value'] = $base_total * -1;
                 if (!ELTransaction::currencyAdjustment($data, $errors)) {
                     $flash->addErrors($errors);
                     $db->FailTrans();
                 }
             }
             if ($db->CompleteTrans()) {
                 $flash->addMessage('Transactions matched');
                 sendBack();
             }
         } else {
             $flash->addError('Transactions must sum to zero');
         }
     }
     $db->FailTrans();
     $this->allocate();
     $this->setTemplatename('allocate');
 }
Exemplo n.º 9
0
 public function savetransaction()
 {
     $flash = Flash::Instance();
     if (!$this->checkParams('model_type')) {
         $flash->addError('model_type not defined');
         sendback();
     }
     if (!$this->checkParams($this->_data['model_type'])) {
         $flash->addError('No input data for ' . $this->_data['model_type']);
         sendback();
     }
     $model = $this->_data['model_type'];
     if (empty($this->_data[$model]['id']) || empty($this->_data[$model]['net_mass'])) {
         $flash->addError('No id or Net Mass value for ' . $model);
         sendback();
     }
     $transaction = DataObjectFactory::Factory($model);
     if ($transaction->netMass != $this->_data[$model]['net_mass']) {
         if (!$transaction->update($this->_data[$model]['id'], 'net_mass', $this->_data[$model]['net_mass'])) {
             $flash->addError('Error updating ' . $model . ' Net Mass value');
         } else {
             $flash->addMessage($model . ' Net Mass value updated');
         }
     }
     sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
 }
Exemplo n.º 10
0
 public function unused()
 {
     $errors = array();
     $s_data = array();
     if (!isset($this->_data['session_data_key'])) {
         // session is not set so this is the first entry
         $this->_data['session_data_key'] = get_class($this->_templateobject) . '-delete-unused';
         $page_data = new SessionData($this->_data['session_data_key']);
         $page_data->registerPageData(array('select'));
     } else {
         $page_data = new SessionData($this->_data['session_data_key']);
     }
     // Update page data if paging
     if (isset($this->_data[$this->modeltype]) && (isset($this->_data['page']) || isset($this->_data['orderby']))) {
         foreach ($this->_data[$this->modeltype] as $id => $fields) {
             if ($fields['select'] == 'on') {
                 $page_data->updatePageData($id, $fields, $errors);
             } else {
                 $page_data->deletePageData($id);
             }
         }
     }
     $data = $page_data->getPageData();
     // Set context from calling module
     $this->setSearch('productlinesSearch', 'customerDefault', $s_data);
     $productlines = new SOProductlineCollection($this->_templateobject);
     $sh = $this->setSearchHandler($productlines);
     if (count($errors) > 0) {
         $flash = Flash::Instance();
         $flash->addErrors($errors);
         sendback();
     }
     $sh->addConstraint(new Constraint('not exists', '', '(select 1 from so_lines where productline_id=so_productlines_overview.id)'));
     $sh->addConstraint(new Constraint('not exists', '', '(select 1 from si_lines where productline_id=so_productlines_overview.id)'));
     parent::index($productlines, $sh);
     if (isset($this->_data['select_all'])) {
         if (count($data) > 0) {
             $page_data->clearPageData();
         } else {
             $productline = DataObjectFactory::Factory($this->modeltype, 'so_productlines_overview');
             // We already have the constraints from above in the search handler
             $cc = $sh->constraints;
             // Just need to get the ids
             foreach ($productline->getAll($cc) as $id => $productline) {
                 $page_data->updatePageData($id, array('select' => 'on'), $errors);
             }
         }
         $data = $page_data->getPageData();
     }
     $sidebar = new SidebarController($this->view);
     $actions = array();
     $actions['all_products'] = array('link' => array('modules' => $this->_modules, 'controller' => 'soproductlineheaders', 'action' => 'index'), 'tag' => 'view all products');
     $actions['all_lines'] = array('link' => array('modules' => $this->_modules, 'controller' => 'soproductlines', 'action' => 'index'), 'tag' => 'view all lines');
     $sidebar->addList('Actions', $actions);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('collection', $productlines);
     $this->view->set('clickaction', 'view_so_product');
     $this->view->set('linkfield', 'productline_header_id');
     $this->view->set('linkvaluefield', 'productline_header_id');
     // set the generic variables for the paging_select template
     $this->view->set('session_data_key', $this->_data['session_data_key']);
     $this->view->set('selected', $data);
     $this->view->set('count_selected', count($data));
     if (count($data) > 0) {
         $this->view->set('select_all_text', 'Clear All');
     } else {
         $this->view->set('select_all_text', 'Select All');
     }
     $this->view->set('submit_text', 'Delete Selected');
     $this->view->set('form_action', 'delete_selected');
     $this->setTemplateName('paging_select');
 }
Exemplo n.º 11
0
if (!$add_user) {
    sendBack('There was a problem adding the key into the database');
}
//send the email or message after adding to the DB
if (USE_MAIL) {
    ## email user about the key ##
    $body = '<html><body>';
    $body .= '<h2>Echelon User Key</h2>';
    $body .= $config['cosmos']['email_header'];
    $body .= 'This is the key you will need to use to register on Echelon. 
				<a href="http://' . $_SERVER['SERVER_NAME'] . PATH . 'register.php?key=' . $user_key . '&amp;email=' . $email . '">Register here</a>.<br />';
    $body .= 'Registration Key: ' . $user_key;
    $body .= $config['cosmos']['email_footer'];
    $body .= '</body></html>';
    // replace %ech_name% in body of email with var from config
    $body = preg_replace('#%ech_name%#', $config['cosmos']['name'], $body);
    // replace %name%
    $body = preg_replace('#%name%#', 'new user', $body);
    $headers = "From: echelon@" . $_SERVER['HTTP_HOST'] . "\r\n";
    $headers .= "Reply-To: " . EMAIL . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $subject = "Echelon User Registration";
    // send email
    if (!mail($email, $subject, $body, $headers)) {
        sendback('There was a problem sending the email.');
    }
    sendGood('Key Setup and Email has been sent to user');
}
// remind the admin to add the new user as they did not recieve an email
sendGood('Don\'t forget to give the user their registration key, since it was not mailed');
Exemplo n.º 12
0
 /**
  * This is here so that viewXXXXXX() can be called for anything that you think you might want to see
  */
 public function __call($method, $args)
 {
     if (strtolower(substr($method, 0, 4)) == 'view') {
         $view_name = substr($method, 4);
         $this->viewRelated($view_name);
         return true;
     }
     if (strtolower(substr($method, 0, 3)) == 'get') {
         if (isset($this->_data['ajax']) && isset($this->_data['id'])) {
             $value = array();
             $id = $this->_data['id'];
             $inflector = new Inflector();
             $property = $inflector->pluralize(strtolower(substr($method, 3)));
             // $model = new $this->modeltype;
             $model = DataObjectFactory::Factory($this->modeltype);
             if (method_exists($model, $method)) {
                 // Use by:-
                 // 1) ajax calls passing in the id of the selected object
                 // which may not be the id of controllers model
                 unset($value);
                 $value = $model->{$method}($id, $this->_data);
             } else {
                 $model->load($id);
                 $hasMany = $model->getHasMany();
                 if (isset($hasMany[$property])) {
                     $collection = $model->{$property};
                     $this->_templateName = 'get';
                     $json = json_encode($collection->getAssoc());
                 } elseif (isset($model->belongsToField[$property])) {
                     $belongsTo = $model->belongsTo[$model->belongsToField[$property]];
                     // $newModel = new $belongsTo['model'];
                     $newModel = DataObjectFactory::Factory($belongsTo['model']);
                     unset($value);
                     $value = $newModel->getAll();
                 } else {
                     $property = substr($method, 3);
                     $value = $model->{$property};
                     $newModel = substr($property, 0, -3);
                     // $newModel = new $newModel;
                     $newModel = DataObjectFactory::Factory($newModel);
                     $newModel->load($value);
                     unset($value);
                     $value[$newModel->{$newModel->idField}] = $newModel->{$newModel->getIdentifier()};
                 }
             }
             echo json_encode($value);
             exit;
         }
     }
     // $this->index();
     $flash = Flash::Instance();
     $flash->addError('Invalid action ' . $this->modeltype . ' ' . $method . ' in ' . $this->name);
     sendback();
 }
Exemplo n.º 13
0
 public function PrintDocument()
 {
     // this is where FOP will need to take place
     // get the XML for the collection, pass it off to an XSLT, could easily use the dialog
     if (!$this->loadData()) {
         sendback();
     }
     $do = $this->_uses[$this->modeltype];
     // set options
     $options = array('type' => array('pdf' => '', 'xml' => ''), 'output' => array('print' => '', 'save' => '', 'email' => '', 'view' => ''), 'report' => 'Document', 'filename' => get_class($do) . '_' . $do->{$do->idField});
     // we use status in other print functions, however here we base it on if ajax print is or isn't set
     if (!$this->isPrinting()) {
         return $options;
     }
     $form_data = $this->decode_original_form_data($this->_data['encoded_query_data']);
     $data = array();
     $tags = array();
     if (isset($form_data['fields'])) {
         $data[$do->idField] = $do->{$do->idField};
         foreach ($form_data['fields'] as $fieldname => $tag) {
             $data[$fieldname] = $do->getFormatted($fieldname);
             $tags[$fieldname] = $tag;
         }
     }
     // TODO: Loop round $do->getFields and add any fields not in $data?
     $options['xslVars']['REPORT_TITLE'] = $do->getTitle();
     $options['xslSource'] = ReportDefinition::getDefinition($this->_data['print']['report'])->definition;
     $options['xmlSource'] = $this->build_custom_xml(array($data), $tags);
     // fire the print output, echo the output JSON for jQuery to handle
     echo $this->generate_output($this->_data['print'], $options);
     exit;
 }
Exemplo n.º 14
0
 public function save()
 {
     $glheader = DataObjectFactory::Factory($this->_header_model);
     $unposted = $glheader->unpostedTransactionFactory();
     $transaction_model = get_class($unposted);
     if (!$this->checkParams(array($this->_header_model, $transaction_model))) {
         $this->dataError();
         sendBack();
     }
     if (!empty($this->_data[$this->_header_model]['id'])) {
         $glheader->load($this->_data[$this->_header_model]['id']);
     }
     if (!$glheader->isLoaded()) {
         $this->dataError('Error loading GL Transaction Header');
         sendback();
     }
     $flash = Flash::Instance();
     $errors = array();
     if (empty($this->_data[$transaction_model]['comment'])) {
         $this->_data[$transaction_model]['comment'] = $glheader->comment;
     }
     if (empty($this->_data[$transaction_model]['reference'])) {
         $this->_data[$transaction_model]['reference'] = $glheader->reference;
     }
     $debit = $this->_data[$transaction_model]['debit'];
     $credit = $this->_data[$transaction_model]['credit'];
     if ($debit < 0 || $credit < 0) {
         $errors[] = 'Credit/Debit values cannot be negative';
     } elseif ($debit == 0 && $credit == 0) {
         $errors[] = 'Can\'t enter a journal line without either a credit or a debit';
     } elseif ($debit > 0 && $credit > 0) {
         $errors[] = 'A journal line cannot have both a credit and a debit';
     }
     $this->_data[$transaction_model]['source'] = 'G';
     $this->_data[$transaction_model]['type'] = 'J';
     $gltransaction = $unposted::Factory($this->_data[$transaction_model], $errors, $unposted);
     if (count($errors) === 0 && $gltransaction && $gltransaction->save()) {
         $flash->addMessage("GL Transaction Journal saved successfully");
         if (isset($this->_data['saveAnother'])) {
             $other = array('header_id' => $this->_data[$this->_header_model]['id'], 'glaccount_id' => $this->_data[$transaction_model]['glaccount_id'], 'glcentre_id' => $this->_data[$transaction_model]['glcentre_id']);
             sendTo($this->name, 'new', $this->_modules, $other);
         }
         sendTo('gltransactionheaders', 'view', $this->_modules, array('id' => $this->data[$this->_header_model]['id']));
     } else {
         $flash->addErrors($errors);
     }
     $this->_data['header_id'] = $this->_data[$this->_header_model]['id'];
     $this->_data['id'] = $this->_data[$transaction_model]['id'];
     $this->refresh();
 }