function chargeSearch($charges, $o) { $r = getRenderer(); $type = isset($o['type']) ? $o['type'] : ''; $company_id = isset($o['company_id']) ? $o['company_id'] : ''; $start_date = isset($o['date_range']['start_date']) ? $o['date_range']['start_date'] : ''; $end_date = isset($o['date_range']['end_date']) ? $o['date_range']['end_date'] : ''; $form = new Form(array('controller' => 'Charge', 'action' => 'search', 'method' => 'get', 'auto_submit' => array('company_id', 'type', 'start_date', 'end_date'), 'ajax_target_id' => 'charges-table')); $charge = new Charge(); $charge->set(array('type' => $type)); $fs = $form->getFieldSetFor($charge); $form->content .= $fs->field('type', array('title' => 'Type', 'name' => 'type')); $form->content .= $r->classSelect('Company', array('title' => 'Client', 'name' => 'company_id', 'id' => 'company_id', 'selected_value' => $company_id)); $form->content .= '<div class="search-input"> <label for="charge_search_start">Start Date</label> ' . $r->input('date', array('name' => 'date_range[start_date]', 'value' => $start_date, 'id' => 'charge_search_start')) . ' </div> <div class="search-input"> <label for="charge_search_end">End Date</label> ' . $r->input('date', array('name' => 'date_range[end_date]', 'value' => $end_date, 'id' => 'charge_search_end')) . ' </div> '; $o['search'] = $form->html; return $r->view('chargeTable', $charges, $o); }
function companyTable($companies, $o = array()) { $r = getRenderer(); $search_form = ''; if (!empty($o['search_company']) && is_a($o['search_company'], 'Company')) { $form = new Form(array('controller' => 'Company', 'action' => 'index', 'method' => 'get', 'auto_submit' => array('org_type', 'country', 'status'))); $f = $form->getFieldSetFor($o['search_company']); $form_content = $f->field('org_type', array('title' => 'Organization Type')); $form_content .= $f->field('country', array('title' => 'Country')); $form_content .= $f->field('status', array('title' => 'Status')); $form->content = $form_content; $search_form = $form->html; } $table = array(); $table['headers'] = array('Client', 'Primary Contact', 'Status', 'Last Payment', 'Billing Status', 'Balance'); $table['rows'] = array(); foreach ($companies as $c) { $link = $r->link('Company', array('action' => 'show', 'id' => $c->id), $c->getName()); if ($c->getPrimaryContact()) { $contact_link = $r->link('Contact', array('action' => 'show', 'id' => $c->getPrimaryContact()->id), $c->getPrimaryContactName()); } else { $contact_link = ''; } $table['rows'][] = array($link, $contact_link, $c->get('status'), $c->getLastPaymentDate(), $c->get('billing_status'), $c->calculateBalance(array('end_date' => Util::date_format_from_time()))); } return $r->view('basicTable', $table, array('title' => 'Search Clients', 'search' => $search_form, 'pager' => true)); }
function projectNewForm($project, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Project', 'action' => 'create')); $f = $form->getFieldSetFor($project); $list_items = array('Name' => $f->name, 'Company' => $f->company_id, 'Internal Project' => $f->internal, 'Status' => $f->status, 'Project_Manager' => $f->staff_id, 'Launch Deadline' => $f->launch_date, 'Discovery Deadline' => $f->discovery_date, 'Notes' => $f->other_notes, 'Domain' => $f->domain_notes, 'Initial Estimated Cost' => $f->cost, 'Hour Cap' => $f->hour_cap, 'Hourly Rate' => $f->hourly_rate, 'Billing Status' => $f->billing_status, 'Server' => $f->server); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Add Project', 'display' => 'inline')); return array('title' => 'New Project', 'body' => $form->html); }
function chargeEditForm($charge, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Charge', 'action' => 'update')); $fs = $form->getFieldSetFor($charge); $form_fields = array('Name' => $fs->name, 'Type' => $fs->type, 'Description' => $fs->description, 'Amount' => $fs->amount, 'Date' => $fs->date, 'Company' => $fs->company_id); $form->content = $r->view('basicFormContents', $form_fields, array('title' => 'Edit Charge')); return $form->html; }
function projectEditForm($p, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Project', 'action' => 'update')); $fs = $form->getFieldSetFor($p); $list_items = array('Name' => $fs->name, 'Status' => $fs->status, 'Internal Project' => $fs->internal, 'Launch Date' => $fs->launch_date, 'Company' => $fs->company_id, 'Project Manager' => $fs->staff_id, 'Designer' => $fs->desinger, 'Domain' => $fs->domain_notes, 'Initial Estimated Cost' => $fs->cost, 'Hour Cap' => $fs->hour_cap, 'Hourly Rate' => $fs->hourly_rate, 'Billing Status' => $fs->billing_status, 'Server' => $fs->server); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Project')); return $form->html; }
function contactEditForm($c, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Contact', 'action' => 'update')); $fs = $form->getFieldSetFor($c); $list_items = array('Company' => $fs->company_id, 'First Name' => $fs->first_name, 'Last Name' => $fs->last_name, 'Email' => $fs->email, 'Phone' => $fs->phone, 'Fax' => $fs->fax, 'Billing Contact' => $fs->is_billing_contact, 'Primary Contact' => $fs->is_primary_contact, 'Technical Contact' => $fs->is_technical_contact); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Contact')); return $form->html; }
function staffEditForm($user) { $r = getRenderer(); $form = new Form(array('controller' => 'Staff', 'action' => 'update')); $fs = $form->getFieldSetFor($user); $fields = array('Username' => $fs->username, 'First Name' => $fs->first_name, 'Last Name' => $fs->last_name, 'Email' => $fs->email, 'Team' => $fs->team, 'New Password' => '<input type="password" name="new_password"/>', 'Repeat Password' => '<input type="password" name="new_password_repeat"/>', 'Avatar' => $fs->avatar, 'Active' => $fs->active); $form->content = $r->view('basicFormContents', $fields, array('title' => 'Edit Staff')); return $form->html; }
function noteEditForm($n, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Note', 'action' => 'update')); $fs = $form->getFieldSetFor($n); $list_items = array('Company' => $fs->company_id, 'Staff' => $fs->staff_id, 'Name' => $fs->name, 'Details' => $fs->description, 'Date' => $fs->date); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Note')); return $form->html; }
function supportcontractNewForm($contract, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'SupportContract', 'action' => 'create')); $fs = $form->getFieldSetFor($contract); $list_items = array('Company' => $fs->company_id, 'Domain Name' => $fs->domain_name, 'Tech' => $fs->technology, 'Support Hours' => $fs->support_hours, 'Hourly Rate' => $fs->hourly_rate, 'Monthly Rate' => $fs->monthly_rate, 'Pro Bono' => $fs->pro_bono, 'Contract On File' => $fs->contract_on_file, 'Status' => $fs->status, 'Not Monthly' => $fs->not_monthly, 'Notes' => $fs->notes, 'Start Date' => $fs->start_date, 'End Date' => $fs->end_date, 'Contract Url' => $fs->contract_url); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'New Contract')); return $form->html; }
function invoiceStandNewForm($invoice, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Invoice', 'action' => 'create')); $fs = $form->getFieldSetFor($invoice); $list_items = array('Amount' => $fs->amount_due, 'Date' => $fs->date, 'Company' => $fs->company_id, 'Details' => $fs->details); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'New Stand-Alone Invoice')); return $form->html; }
function clientuserEditForm($user) { $r = getRenderer(); $form = new Form(array('controller' => 'ClientUser', 'action' => 'update')); $fs = $form->getFieldSetFor($user); $fields = array('First Name' => $fs->first_name, 'Last Name' => $fs->last_name, 'Company' => $fs->company_id, 'Email' => $fs->email, 'New Password' => '<input type="text" name="new_password"/>'); $form->content = $r->view('basicFormContents', $fields, array('title' => 'Edit Client User')); return $form->html; }
function clientuserNewForm($user) { $r = getRenderer(); $form = new Form(array('controller' => 'ClientUser', 'action' => 'create')); $fs = $form->getFieldSetFor($user); $fields = array('First Name' => $fs->first_name, 'Last Name' => $fs->last_name, 'Company' => $fs->company_id, 'Email' => $fs->email, 'Password' => $fs->password); $form->content = $r->view('basicFormContents', $fields, array('title' => 'New Client User')); return $form->html; }
function estimateEditForm($e, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Estimate', 'action' => 'update')); $fs = $form->getFieldSetFor($e); $list_items = array('Name' => $fs->name, 'Description' => $fs->description, 'Low Estimate' => $fs->low_hours, 'High Estimate' => $fs->high_hours, 'Due Date' => $fs->due_date, 'Internal Details' => $fs->notes, 'Project' => $fs->project_id, 'Category' => $fs->category); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Estimate')); return $form->html; }
function invoicebatchNewForm($batch, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'InvoiceBatch', 'action' => 'create')); $fs = $form->getFieldSetFor($batch); $list_items = array('Name' => $fs->name, 'Start Date' => $fs->start_date, 'End Date' => $fs->end_date, 'Created Date' => $fs->created_date); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'New Invoice Batch')); return $form->html; }
function supportcontractCancelForm($contract, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'SupportContract', 'action' => 'process_cancellation')); $fs = $form->getFieldSetFor($contract); $list_items = array('End Date' => $fs->end_date, 'Company' => $contract->get('company_id'), 'Domain Name' => $contract->get('domain_name'), 'Tech' => $contract->get('technology'), 'Support Hours' => $contract->get('support_hours'), 'Hourly Rate' => $contract->get('hourly_rate'), 'Monthly Rate' => $contract->get('monthly_rate'), 'Pro Bono' => $contract->get('pro_bono'), 'Contract On File' => $contract->get('contract_on_file'), 'Status' => $contract->get('status'), 'Not Monthly' => $contract->get('not_monthly'), 'Notes' => $contract->get('notes'), 'Start Date' => $contract->get('start_date'), 'Contract Url' => $contract->get('contract_url')); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Renew Contract')); return $form->html; }
function companyEditForm($c, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Company', 'action' => 'update')); $fs = $form->getFieldSetFor($c); $list_items = array('Name' => $fs->name, 'Alias' => $fs->alias, 'Status' => $fs->status, 'Type' => $fs->org_type, 'Bay Area' => $fs->bay_area, 'Street' => $fs->street, 'Street 2' => $fs->street_2, 'City' => $fs->city, 'State' => $fs->state, 'Zip' => $fs->zip, 'Country' => $fs->country, 'Start Date' => $fs->date_started, 'Close Date' => $fs->date_ended, 'Billing Status' => $fs->billing_status, 'Notes' => $fs->notes); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Client')); return $form->html; }
function invoiceEditForm($invoice, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Invoice', 'action' => 'update')); $fs = $form->getFieldSetFor($invoice); $list_items = array('Start Date' => $fs->start_date, 'End Date' => $fs->end_date, 'Company' => $fs->company_id, 'Additional Recipients' => $fs->additional_recipients, 'Status' => $fs->payment_status); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Standard Invoice')); return $form->html; }
function supporthourEditForm($h, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'SupportHour', 'action' => 'update')); $fs = $form->getFieldSetFor($h); $list_items = array('Support Contract' => $fs->support_contract_id, 'Description' => $fs->description, 'Staff' => $fs->staff_id, 'Pair' => $fs->field('pair_id', array('select_none' => 'Not Paired')), 'Hours' => $fs->hours, 'Discount' => $fs->discount, 'Date Completed' => $fs->date); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Hour', 'display' => 'inline')); return '<div id="edit-hours-for-support">' . $form->html . '</div>'; }
function hourEditForm($h, $o) { $r = getRenderer(); $options = $o; $form = new Form(array('controller' => 'Hour', 'action' => 'update')); $fs = $form->getFieldSetFor($h); $project_id = $o['project_id']; $estimate_field = $fs->field('estimate_id', array('project_id' => $project_id)); $list_items = array('Estimate' => $estimate_field, 'Description' => $fs->description, 'Date Completed' => $fs->date, 'Pair' => $fs->field('pair_id', array('select_none' => 'Not Paired')), 'Hours' => $fs->hours, 'Discount' => $fs->discount, 'Staff' => $fs->staff_id); $form->content = $r->view('basicFormContents', $list_items, array('title' => 'Edit Hour: ' . $h->getName(), 'display' => 'inline')); return $form->html; }
function paymentNewForm($payment, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Payment', 'action' => 'create')); if (isset($o['redirect'])) { $form_options['redirect'] = $o['redirect']; } $fs = $form->getFieldSetFor($payment); $form_fields = array('Company' => $fs->company_id, 'Invoice ID' => $fs->invoice_id, 'Amount' => $fs->amount, 'Date' => $fs->date, 'Payment Type' => $fs->payment_type, 'Check No.' => $fs->check_number, 'Purpose' => $fs->purpose, 'Notes' => $fs->notes, 'Don\'t Send Reciept' => '<input type="checkbox" value="1" name="noemail" id="noemail">'); $form->content = $r->view('basicFormContents', $form_fields, array('title' => 'New Payment')); return $form->html; }
function paymentEditForm($payment, $o = array()) { $r = getRenderer(); $form_options = array('controller' => 'Payment', 'action' => 'update'); if (isset($o['redirect'])) { $form_options['redirect'] = $o['redirect']; } $form = new Form($form_options); $fs = $form->getFieldSetFor($payment); $form_fields = array('Company' => $fs->company_id, 'Invoice ID' => $fs->invoice_id, 'Amount' => $fs->amount, 'Date' => $fs->date, 'Payment Type' => $fs->payment_type, 'Check No.' => $fs->check_number, 'Purpose' => $fs->purpose, 'Notes' => $fs->notes); $form->content = $r->view('basicFormContents', $form_fields, array('title' => 'Edit Payment')); return $form->html; }
function hourNewForm($h, $o = array()) { $r = getRenderer(); $form = new Form(array('controller' => 'Hour', 'action' => 'create')); $fs = $form->getFieldSetFor($h); if (isset($o['project_id'])) { $estimate_field = $fs->field('estimate_id', array('project_id' => $o['project_id'])); } else { $estimate_field = $fs->estimate_id; } $list_items = array('Estimate' => $estimate_field, 'Description' => $fs->description, 'Staff' => $fs->staff_id, 'Pair' => $fs->field('pair_id', array('select_none' => 'Not Paired', 'active' => 'true')), 'Hours' => $fs->hours, 'Discount' => $fs->discount, 'Date Completed' => $fs->date); isset($o['title']) ? $title = 'Add Hour: ' . $o['title'] : ($title = 'Add Hour'); $form->content = $r->view('basicFormContents', $list_items, array('title' => $title, 'display' => 'inline')); return $form->html; }
function bookmarkNewForm($d, $o = array()) { $url = parse_url($_SERVER['HTTP_REFERER']); $local_url = $url['path']; if (isset($url['query']) && $url['query'] != '') { $local_url .= '?' . $url['query']; } $r = getRenderer(); $form = new Form(array('controller' => 'Bookmark', 'action' => 'create')); $fs = $form->getFieldSetFor($d->bookmark); $html .= $fs->field('staff_id', array('field_type' => 'hidden')); $html .= '<input type="hidden" value="' . $local_url . '" id="ActiveRecord[Bookmark][new-0][source]" class="source-field Bookmark-field hidden-field" name="ActiveRecord[Bookmark][new-0][source]">'; $html .= $fs->description; $html .= $form->getSubmitBtn(); $form->content = $html; return $form->html; }
function testCreateFormForOneObject() { $hour = new Hour(); $hour->set(array('description' => 'SimpleTest Hour Description 2', 'support_contract_id' => 1, 'date' => '2010-02-20', 'hours' => '2.5', 'discount' => '1')); $hour->save(); $hour_id = $hour->get('id'); $form = new Form(array('controller' => 'Hour', 'action' => 'update', 'method' => 'post')); $f = $form->getFieldSetFor($hour); $html = $f->description; $html .= $f->hours; $html .= $f->discount; $form->content = $html; $form_html = $form->html; $correct_html = '<form method="post" action="index.php" class = "standard-form" > <input type="hidden" name="controller" value="Hour"/> <input type="hidden" name="action" value="update"/> <input type="text" value="SimpleTest Hour Description 2" id = "ActiveRecord[Hour][' . $hour_id . '][description]" class = "description-field Hour-field text-field" name = "ActiveRecord[Hour][' . $hour_id . '][description]" /><input type="text" value="2.5" id = "ActiveRecord[Hour][' . $hour_id . '][hours]" class = "hours-field Hour-field float-field" name = "ActiveRecord[Hour][' . $hour_id . '][hours]" /><input type="text" value="1" id = "ActiveRecord[Hour][' . $hour_id . '][discount]" class = "discount-field Hour-field float-field" name = "ActiveRecord[Hour][' . $hour_id . '][discount]" /><div class="submit-container"><input type="submit" class="submit_btn" value="submit"/></div> </form> '; $this->assertEqual($correct_html, $form_html); $hour->delete(); }
function projectTable($projects, $o = array()) { if (!$projects) { return; } $r = getRenderer(); $search_form = ''; if (!empty($o['search_project']) && is_a($o['search_project'], 'Project')) { $form = new Form(array('controller' => 'Project', 'action' => 'index', 'method' => 'get', 'auto_submit' => array('org_type', 'country', 'status'))); $f = $form->getFieldSetFor($o['search_project']); $form_content .= $f->field('status', array('title' => 'Status')); $form->content = $form_content; $search_form = $form->html; } $table = array(); $table['headers'] = array('ID', 'Project Name', 'Status', 'Project Manager', 'Launch Date', 'Billing Status', 'Total Cost Est', 'Hours'); $table['rows'] = array(); foreach ($projects as $p) { $table['rows'][] = array($p->id, $r->link('Project', array('action' => 'show', 'id' => $p->id), $p->getName()), $p->get('status'), $p->getStaffName(), $p->get('launch_date'), $p->get('billing_status'), $p->get('cost'), $p->getBillableHours()); } $html = $r->view('basicTable', $table, array('title' => 'Projects', 'search' => $search_form, 'pager' => true)); return $html; }
function companyKneecapsTable($companies, $o = array()) { $r = getRenderer(); $search_form = ''; if (!empty($o['search_company']) && is_a($o['search_company'], 'Company')) { $form = new Form(array('controller' => 'Company', 'action' => 'kneecaps', 'method' => 'get', 'auto_submit' => array('status'))); $f = $form->getFieldSetFor($o['search_company']); $form_content = $f->field('status', array('title' => 'Status')); $form->content = $form_content; $search_form = $form->html; } $table = array(); $table['headers'] = array('Client', 'Billing Name', 'Billing Email', 'Billing Phone', ' Status', 'Last Payment', 'Billing Status', 'Balance'); $table['rows'] = array(); foreach ($companies as $c) { $link = $r->link('Company', array('action' => 'show', 'id' => $c->id), $c->getName()); $contact_link = $r->link('Contact', array('action' => 'show', 'id' => $c->getBillingContact()->id), $c->getBillingContactName()); $contact_email = '<a href="mailto:' . $c->getBillingEmailAddress() . '">' . $c->getBillingEmailAddress() . '</a>'; $contact_phone = $c->getBillingPhone(); $table['rows'][] = array($link, $contact_link, $contact_email, $contact_phone, $c->get('status'), $c->getLastPaymentDate(), $c->get('billing_status'), $c->calculateBalance(array('end_date' => Util::date_format_from_time()))); } return $r->view('basicTable', $table, array('title' => 'Search Clients', 'search' => $search_form, 'pager' => true)); }
function paymentSearch($payments, $o) { $r = getRenderer(); $type = isset($o['type']) ? $o['type'] : ''; $company_id = isset($o['company_id']) ? $o['company_id'] : ''; $start_date = isset($o['date_range']['start_date']) ? $o['date_range']['start_date'] : ''; $end_date = isset($o['date_range']['end_date']) ? $o['date_range']['end_date'] : ''; $form = new Form(array('controller' => 'Payment', 'action' => 'search', 'method' => 'get', 'auto_submit' => array('company_id', 'payment_type', 'start_date', 'end_date'), 'ajax_target_id' => 'payments-table')); isset($o['search_payment']) ? $payment = $o['search_payment'] : ($payment = new Payment()); $fs = $form->getFieldSetFor($payment); $form->content = $fs->field('payment_type', array('title' => 'Payment Type')); $form->content .= $fs->field('company_id', array('title' => 'Client')); $form->content .= '<div class="search-input"> <label for="payment_search_start">Start Date</label> ' . $r->input('date', array('name' => 'date_range[start_date]', 'value' => $start_date, 'id' => 'payment_search_start')) . ' </div> <div class="search-input"> <label for="payment_search_end">End Date</label> ' . $r->input('date', array('name' => 'date_range[end_date]', 'value' => $end_date, 'id' => 'payment_search_end')) . ' </div> '; $o['search'] = $form->html; return $r->view('paymentTable', $payments, $o); }