<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../../lib/test/otokouTestFunctional.class.php';
$browser = new otokouTestFunctional(new sfBrowser());
$browser->loadData()->login();
$browser->setTester('doctrine', 'sfTesterDoctrine');
$fuelId = $browser->getIdForCategory('Fuel');
$browser->test()->is(sfConfig::get('app_list_nb_links'), 5);
$browser->info('1 - The charge form')->info('  1.1 - If "fuel" category is selected, a quantity must be specified')->get('/charge/new')->with('response')->isStatusCode(404)->get('/ruf/charge/new')->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'new')->end()->with('response')->begin()->checkElement('select#charge_date_day option[selected="selected"]', date('d'))->checkElement('select#charge_date_month option[selected="selected"]', date('m'))->checkElement('select#charge_date_year option[selected="selected"]', date('Y'))->checkElement('select#charge_date_year:contains(1970)', true)->checkElement('#charge_new_menu', true)->checkElement('#charge_new_menu li:contains("Add a new vehicle")', true)->end()->click('Save', getFormData($browser, array('category_id' => $fuelId, 'quantity' => null)))->with('form')->begin()->hasErrors(1)->isError('quantity', '/quantity/')->end()->click('Save', getFormData($browser, array('category_id' => $fuelId, 'quantity' => 12)))->with('form')->begin()->hasErrors(false)->end()->info(' 1.2 - If any other category is selected, the quantity cannot be specified')->get('/ruf/charge/new')->click('Save', getFormData($browser, array('category_id' => $browser->getIdForCategory('Tax'), 'quantity' => 12)))->with('form')->begin()->hasErrors(1)->isError('quantity', '/quantity/')->end()->click('Save', getFormData($browser, array('category_id' => $browser->getIdForCategory('Tax'), 'quantity' => null)))->with('form')->begin()->hasErrors(false)->end()->info('  1.3 - The "Save" button redirects to object edit')->get('/ruf/charge/new')->click('Save', getFormData($browser, array('category_id' => $browser->getIdForCategory('Tax'), 'quantity' => null)))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'edit')->end()->info('  1.4 - The "Save and add" button redirects to a new charge input form')->get('/ruf/charge/new')->click('Save and add', getFormData($browser, array('category_id' => $browser->getIdForCategory('Tax'), 'quantity' => null)))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'new')->end()->info('2 - Data access rights')->logout()->login('user2', 'user2')->info('  2.1 - A user can only see his charges in list')->get('/charge')->with('response')->isStatusCode(404)->get('/user2/charge')->with('request')->begin()->isParameter('username', 'user2')->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 1)->end()->with('user')->begin()->hasCredential('owner')->end()->info('  2.2 - A user cannot see other users charges list')->get('/ruf/charge')->with('request')->begin()->isParameter('username', 'ruf')->end()->with('response')->begin()->isStatusCode(403)->end()->with('user')->begin()->hasCredential('owner', false)->end()->info('  2.3 - A user cannot edit other user\'s charges')->get('/ruf/charge/' . $browser->getOneChargeByParams(array('user_id' => $browser->getUserId('ruf')))->getId() . '/edit')->with('response')->begin()->isStatusCode(403)->end()->with('user')->begin()->hasCredential('owner', false)->end()->get('/user2/charge/' . $browser->getOneChargeByParams(array('user_id' => $browser->getUserId('user2')))->getId() . '/edit')->with('response')->begin()->isStatusCode(200)->end()->with('user')->begin()->hasCredential('owner', true)->end()->info('  2.4 - A user cannot delete other user\'s charges')->call('/ruf/charge/' . $browser->getOneChargeByParams(array('user_id' => $browser->getUserId('ruf')))->getId(), 'delete', array('_with_csrf' => true))->with('response')->begin()->isStatusCode(403)->end()->with('user')->begin()->hasCredential('owner', false)->end()->with('doctrine')->begin()->check('Charge', array('id' => $id = $browser->getOneChargeByParams(array('user_id' => $browser->getUserId('user2')))->getId()), true)->end()->call('/user2/charge/' . $id, 'delete', array('_with_csrf' => true))->with('doctrine')->begin()->check('Charge', array('id' => $id), false)->end()->with('user')->begin()->hasCredential('owner', true)->end()->info('  2.5 - A user cannot create charges for other users')->get('/ruf/charge/new')->with('response')->begin()->isStatusCode(403)->end()->with('user')->begin()->hasCredential('owner', false)->end()->info('3 - Vehicle choices')->info('  3.1 - A user can only see his cars')->logout()->login('ruf', 'admin@1')->get('/ruf/charge/new')->with('response')->begin()->checkElement('select#charge_vehicle_id option', 1)->end()->info('  3.2 - A user cannot select other user\'s vechicles')->click('Save', getFormData($browser, array('vehicle_id' => $browser->getVehicleId('car3'))))->with('form')->begin()->hasErrors(1)->isError('vehicle_id', '/invalid/')->end()->info('  3.3 - A user cannot select non-registered vechicles')->click('Save', getFormData($browser, array('vehicle_id' => $browser->getVehicleId('car-non-existent', false))))->with('form')->begin()->hasErrors(1)->isError('vehicle_id', '/required/')->end()->info('  3.4 - A user can only select his own vechicles')->click('Save', getFormData($browser, array('vehicle_id' => $browser->getVehicleId('vw-touran-1-4-tsi'))))->with('form')->begin()->hasErrors(false)->end()->info('4 - List filters')->logout()->login('ruf', 'admin@1')->info(' 4.1 Show/hide filters without javascript')->get('/user_vehicle/charge')->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filters', false)->end()->click('Show/hide filters')->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'toggleFilterVisibility')->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filter', true)->end()->click('Show/hide filters')->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'toggleFilterVisibility')->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filter', false)->end()->info(' 4.2 Show/hide filters with ajax')->setHttpHeader('X-Requested-With', 'XMLHttpRequest')->click('Show/hide filters')->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'toggleFilterVisibility')->end()->with('response')->begin()->isRedirected(false)->checkElement('div#filters', false)->checkElement('div.sf_admin_filter', true)->end()->get('/user_vehicle/charge')->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filter', true)->end()->setHttpHeader('X-Requested-With', 'XMLHttpRequest')->click('Show/hide filters')->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'toggleFilterVisibility')->end()->with('response')->begin()->isRedirected(false)->checkElement('div#filters', false)->checkElement('div.sf_admin_filter', false)->end()->get('/user_vehicle/charge')->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filter', false)->end()->info('  4.3 - Vehicle: the user can see only his vehicles in the list')->post('/user_vehicle/charge/filter-visibility')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('div#filters', true)->checkElement('div#filters div.sf_admin_filter', true)->checkElement('.sf_admin_filter_field_vehicle_id ul li', 1)->checkElement('.sf_admin_filter_field_vehicle_id ul li input[checked="checked"]', 0)->checkElement('.sf_admin_filter_field_category_id ul li input[checked="checked"]', 0)->end()->info('  4.4 - Vehicle: the filtering works')->click('Filter', array('charge_filters' => array('vehicle_id' => $browser->getVehicleId('car2'))))->with('form')->begin()->hasErrors(1)->isError('vehicle_id', '/invalid/')->end()->click('Filter', array('charge_filters' => array('vehicle_id' => $browser->getVehicleId('vw-touran-1-4-tsi'))))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 16)->end()->with('doctrine')->begin()->check('Charge', array('vehicle_id' => $browser->getVehicleId('vw-touran-1-4-tsi'), 'user_id' => $browser->getUserId('ruf')), 16)->end()->info('  4.5 - The user can select multiple categories')->call('/ruf/charge/filter/action?_reset', 'post', array('_with_csrf' => true))->with('response')->begin()->isRedirected()->isStatusCode(302)->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'index')->end()->click('Filter', array('charge_filters' => array('category_id' => array($browser->getIdForCategory('Insurance'), $browser->getIdForCategory('Tax')))))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->isStatusCode(302)->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 8)->end()->with('doctrine')->begin()->check('Charge', Doctrine_Core::getTable('Charge')->createQuery('a')->WhereIn('a.category_id', array($browser->getIdForCategory('Insurance'), $browser->getIdForCategory('Tax')))->andWhere('a.user_id = ?', $browser->getUserId('ruf')), 8)->end()->click('Filter', array('charge_filters' => array('category_id' => array($browser->getIdForCategory('Insurance'), $browser->getIdForCategory('Fuel')))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 10)->end()->with('doctrine')->begin()->check('Charge', Doctrine_Core::getTable('Charge')->createQuery('a')->WhereIn('a.category_id', array($browser->getIdForCategory('Insurance'), $browser->getIdForCategory('Fuel')))->andWhere('a.user_id = ?', $browser->getUserId('ruf')), 10)->end()->info('  4.6 - Kilometers (and Amount and quantity): the range filter works')->call('/ruf/charge/filter/action?_reset', 'post', array('_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end()->click('Filter', array('charge_filters' => array('kilometers' => array('from' => 0))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 16)->end()->click('Filter', array('charge_filters' => array('kilometers' => array('from' => 35, 'to' => 500))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 9)->end()->click('Filter', array('charge_filters' => array('kilometers' => array('from' => null, 'to' => 1500))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 15)->end()->click('Filter', array('charge_filters' => array('kilometers' => array('to' => null))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 16)->end()->info('  4.7 - When no charges can be found, the sums are null')->click('Filter', array('charge_filters' => array('kilometers' => array('from' => 1001, 'to' => 1002))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 0)->checkElement('div#charges_sum_amount_total', '/All pages: 0 CHF/')->checkElement('div#charges_sum_amount_page', '/This page: 0 CHF/')->end()->info('  4.8 - Comments search')->call('/ruf/charge/filter/action?_reset', 'post', array('_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end()->click('Filter', array('charge_filters' => array('comment' => array('text' => 'tra'))))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 4)->end()->with('doctrine')->begin()->check('Charge', Doctrine_Core::getTable('Charge')->createQuery('a')->where('a.comment LIKE ?', '%tra%'), 4)->end()->info('  4.9 - Filters deletion after logout and change user')->logout()->with('user')->begin()->isAuthenticated(false)->isAttribute('charge.filters', null, 'admin_module')->end()->login('user3', 'user3')->with('user')->begin()->isAuthenticated(true)->isAttribute('charge.filters', null, 'admin_module')->end()->info('5 - Pagination')->logout()->login('user3', 'user3')->info('  5.1 - The number of displayed elements to show in list can be changed')->get('/user3/charge')->with('response')->begin()->checkElement('form.max_per_page', true)->checkElement('select#max_per_page option[selected="selected"][value=20]', 1)->checkElement('div.sf_admin_pagination', true)->checkElement('div#charges_sum_amount_total', '/3,565.0/')->checkElement('div#charges_sum_amount_page', '/2,190.0/')->end()->info('  5.2 - By default, charges list show 20 elements')->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 20)->end()->info('  5.3 - If the User defines a different default value in his settings, the number of elements matches his choice')->logout()->login('user4', 'user4')->get('/user4/charge')->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 5)->checkElement('select#max_per_page option[selected="selected"][value=5]', 1)->checkElement('div#charges_sum_amount_total', '/19,440.0/')->checkElement('div#charges_sum_amount_page', '/1,010.0/')->end()->with('doctrine')->begin()->check('sfGuardUser', array('username' => 'user4', 'list_max_per_page' => 5), true)->end()->info('  5.4 - The user can navigate through multiple pages')->click('a[href*="page=2"]')->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 5)->checkElement('select#max_per_page option[selected="selected"][value=5]', 1)->checkElement('div#charges_sum_amount_total', '/19,440.0/')->checkElement('div#charges_sum_amount_page', '/1,035.0/')->end()->info('  5.5 - If the number of elements is changed, the value is saved in user\\s settings')->post('/user4/charge/maxPerPage/action', array('max_per_page' => 3))->with('request')->begin()->isParameter('action', 'maxPerPage')->isParameter('max_per_page', 3)->end()->with('response')->begin()->isRedirected(false)->checkElement('ul.error_list:contains(Invalid)', true)->checkElement('select#max_per_page option[selected="selected"]', false)->checkElement('div.sf_admin_list tbody tr', 5)->checkElement('div#charges_sum_amount_total', '/19,440.0/')->checkElement('div#charges_sum_amount_page', '/1,035.0/')->end()->post('/user4/charge/maxPerPage/action', array('max_per_page' => 10))->with('request')->begin()->isParameter('action', 'maxPerPage')->isParameter('max_per_page', 10)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('ul.error_list:contains(Invalid)', false)->checkElement('div.sf_admin_list tbody tr', 10)->checkElement('select#max_per_page option[selected="selected"][value=10]', 1)->checkElement('.sf_admin_pagination a[href*="page=2"]', true)->checkElement('div#charges_sum_amount_total', '/19,440.0/')->checkElement('div#charges_sum_amount_page', '/2,045.0/')->end()->with('doctrine')->begin()->check('sfGuardUser', array('username' => 'user4', 'list_max_per_page' => 10), true)->end()->post('/user4/charge/maxPerPage/action', array('max_per_page' => 1000))->with('request')->begin()->isParameter('action', 'maxPerPage')->isParameter('max_per_page', 1000)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('ul.error_list:contains(Invalid)', false)->checkElement('div.sf_admin_list tbody tr', 81)->checkElement('select#max_per_page option[selected="selected"][value=1000]', 1)->checkElement('.sf_admin_pagination a[href*="page=2"]', false)->checkElement('div#charges_sum_amount_total', '/19,440.0/')->checkElement('div#charges_sum_amount_page', '/19,440.0/')->end()->with('doctrine')->begin()->check('sfGuardUser', array('username' => 'user4', 'list_max_per_page' => 1000), true)->end()->info('  5.6 - Changing the number of elements returns to page 1 and displays the requested number of elements')->post('/user4/charge/maxPerPage/action', array('max_per_page' => 50))->with('request')->begin()->isParameter('action', 'maxPerPage')->isParameter('max_per_page', 50)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 50)->checkElement('select#max_per_page option[selected="selected"][value=50]', 1)->checkElement('.sf_admin_pagination a[href*="page=2"]', true)->end()->info('  5.7 Pagination links: page 1')->post('/user4/charge/maxPerPage/action', array('max_per_page' => 5))->with('request')->begin()->isParameter('action', 'maxPerPage')->isParameter('max_per_page', 5)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('div.sf_admin_list tbody tr', 5)->checkElement('select#max_per_page option[selected="selected"][value=5]', 1)->checkElement('.sf_admin_pagination a:contains("Previous")', false)->checkElement('.sf_admin_pagination span[class="thepage"]', "1")->checkElement('.sf_admin_pagination span:contains(...)', 1)->checkElement('.sf_admin_pagination span:contains(|)', 1)->checkElement('.sf_admin_pagination a[href$="page=1"]', false)->checkElement('.sf_admin_pagination a[href$="page=2"]', true)->checkElement('.sf_admin_pagination a[href$="page=3"]', true)->checkElement('.sf_admin_pagination a[href$="page=4"]', true)->checkElement('.sf_admin_pagination a[href$="page=5"]', true)->checkElement('.sf_admin_pagination a[href$="page=6"]', false)->checkElement('.sf_admin_pagination a[href$="page=17"]', 1)->checkElement('.sf_admin_pagination a:contains(Next)', true)->end()->info('  5.8 Pagination links: page 3')->click('a[href*="page=3"]')->with('response')->begin()->checkElement('.sf_admin_pagination a:contains("Previous")', true)->checkElement('.sf_admin_pagination span[class="thepage"]', "3")->checkElement('.sf_admin_pagination span:contains(...)', 1)->checkElement('.sf_admin_pagination span:contains(|)', 2)->checkElement('.sf_admin_pagination a[href$="page=1"]', 1)->checkElement('.sf_admin_pagination a[href$="page=2"]', true)->checkElement('.sf_admin_pagination a[href$="page=3"]', false)->checkElement('.sf_admin_pagination a[href$="page=4"]', true)->checkElement('.sf_admin_pagination a[href$="page=5"]', true)->checkElement('.sf_admin_pagination a[href$="page=6"]', false)->checkElement('.sf_admin_pagination a[href$="page=17"]', 1)->checkElement('.sf_admin_pagination a:contains(Next)', true)->end()->info('  5.9 Pagination links: page 8')->get('user4/charge?page=8')->with('response')->begin()->checkElement('.sf_admin_pagination a:contains("Previous")', true)->checkElement('.sf_admin_pagination span[class="thepage"]', "8")->checkElement('.sf_admin_pagination span:contains(...)', 2)->checkElement('.sf_admin_pagination span:contains(|)', 2)->checkElement('.sf_admin_pagination a[href$="page=1"]', 1)->checkElement('.sf_admin_pagination a[href$="page=5"]', false)->checkElement('.sf_admin_pagination a[href$="page=6"]', true)->checkElement('.sf_admin_pagination a[href$="page=7"]', true)->checkElement('.sf_admin_pagination a[href$="page=8"]', false)->checkElement('.sf_admin_pagination a[href$="page=9"]', true)->checkElement('.sf_admin_pagination a[href$="page=10"]', true)->checkElement('.sf_admin_pagination a[href$="page=11"]', false)->checkElement('.sf_admin_pagination a[href$="page=17"]', 1)->checkElement('.sf_admin_pagination a:contains(Next)', true)->end()->info('  5.10 Pagination links: page 15')->get('user4/charge?page=15')->with('response')->begin()->checkElement('.sf_admin_pagination a:contains("Previous")', true)->checkElement('.sf_admin_pagination span[class="thepage"]', "15")->checkElement('.sf_admin_pagination span:contains(...)', 1)->checkElement('.sf_admin_pagination span:contains(|)', 2)->checkElement('.sf_admin_pagination a[href$="page=1"]', 1)->checkElement('.sf_admin_pagination a[href$="page=12"]', false)->checkElement('.sf_admin_pagination a[href$="page=13"]', true)->checkElement('.sf_admin_pagination a[href$="page=14"]', true)->checkElement('.sf_admin_pagination a[href$="page=15"]', false)->checkElement('.sf_admin_pagination a[href$="page=16"]', true)->checkElement('.sf_admin_pagination a[href$="page=17"]', 1)->checkElement('.sf_admin_pagination a:contains(Next)', true)->end()->info('  5.11 Pagination links: page 17')->get('user4/charge?page=17')->with('response')->begin()->checkElement('.sf_admin_pagination a:contains("Previous")', true)->checkElement('.sf_admin_pagination span[class="thepage"]', "17")->checkElement('.sf_admin_pagination span:contains(...)', 1)->checkElement('.sf_admin_pagination span:contains(|)', 1)->checkElement('.sf_admin_pagination a[href$="page=1"]', 1)->checkElement('.sf_admin_pagination a[href$="page=12"]', false)->checkElement('.sf_admin_pagination a[href$="page=13"]', true)->checkElement('.sf_admin_pagination a[href$="page=14"]', true)->checkElement('.sf_admin_pagination a[href$="page=15"]', true)->checkElement('.sf_admin_pagination a[href$="page=16"]', true)->checkElement('.sf_admin_pagination a[href$="page=17"]', false)->checkElement('.sf_admin_pagination a:contains(Next)', false)->end()->info('6 - Edit')->get('/user4/charge/' . $browser->getOneChargeByParams(array('user_id' => $browser->getUserId('user4')))->getId() . '/edit')->with('response')->begin()->checkElement('select#charge_date_day option[selected="selected"]', '03')->checkElement('select#charge_date_month option[selected="selected"]', '01')->checkElement('select#charge_date_year option[selected="selected"]', '2011')->checkElement('select#charge_date_year:contains(1970)', true)->end()->info('7 - New user')->logout()->login('user_gb_noCars', 'user')->with('doctrine')->begin()->check('Vehicle', array('user_id' => $browser->getUserId('user_gb_noCars'), 'is_archived' => false), 0)->end()->get('/user_gb_noCars/charge/new')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'noVehicle')->end()->with('response')->begin()->checkElement('form', true)->checkElement('h1', '/Add a new vehicle/')->end()->click('Save')->with('form')->begin()->hasErrors(1)->isError('name', '/required/')->end()->click('Save', array('vehicle' => array('name' => 'user_gb_noCars_1', 'is_archived' => true)))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'new')->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'noVehicle')->end()->with('response')->begin()->checkElement('form', true)->checkElement('h1', '/Add a new vehicle/')->end()->click('Save', array('vehicle' => array('name' => 'user_gb_noCars_2', 'is_archived' => false)))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'charge')->isParameter('action', 'new')->end()->with('response')->begin()->isRedirected(false)->end();
function getFormData($browser, $fields = array())
{
    $formFields = array('category_id' => $browser->getIdForCategory('Tax'), 'vehicle_id' => $browser->getVehicleId('vw-touran-1-4-tsi'), 'kilometers' => 100, 'amount' => 22, 'comment' => '', 'quantity' => null, 'date' => array('day' => 3, 'month' => 2, 'year' => 2010));
    return array('charge' => array_merge($formFields, $fields));
}
Exemple #2
0
<input type='submit' name='submit_html' value='<?php 
    xl('Print (HTML)', 'e');
    ?>
'>
</td><td>
</td></tr>
</table>
</form>
</body>
</html>
<?php 
}
if ($_POST['submit_pdf'] || $_POST['submit_html'] || $_GET['pid'] && $_GET['encounter']) {
    // note we are cleaning input, trimming, and preparing the variables for database insert
    //  before sending through this function
    $output = getFormData(formData("start", "P", true), formData("end", "P", true), formData("lname", "P", true), formData("fname", "P", true));
    ksort($output);
    if ($_POST['submit_html']) {
        //print as html
        ?>
        <html>
        <head>
        <style>
        body {
	 font-family: sans-serif;
	 font-weight: normal;
	 font-size: 8pt;
	 background: white;
	 color: black;
	}	
	.paddingdiv {
Exemple #3
0
        printf("\t<DIV ALIGN=\"right\">\n\t\t<FONT FACE=\"%s\" SIZE=\"-1\"><A TARGET=\"_top\" HREF=\"http://www.digitalgenesis.com\">DGS Search %s</A></FONT>\n\t</DIV>\n", $fonts, $config["version"]);
    }
    /* Display footer if set. */
    if ($footer) {
        if ($footer[0] != $fileSeparator && $footer[0] != '.') {
            $footer = $installBase . $fileSeparator . 'config' . $fileSeparator . $footer;
        }
        if (is_readable($footer)) {
            include $footer;
        } else {
            printf("Error: Unable to access footer '%s'.<BR>\n", $footer);
        }
    }
}
/* Start of Main */
$data = getFormData();
if ($data['debug']) {
    if (!remoteDebug($debug, $option)) {
        return;
    }
}
$timer = getTime();
if ($config['debug']) {
    printf("Debug: main() - Calling processConfig()<BR>\n");
}
$status = processConfig();
if ($status) {
    /* Clean up and localize passed values. */
    $r = !isset($data['r']) ? $config['results'] ? 10 : $config['results'] : $data['r'];
    //Set default for results per page.
    $r = $r < 1 ? $config['maxResults'] : $r;