public function __construct($session_array = '', $car_id = '') { // Header echo parent::getHeader('Car Details'); // Get the proper car from the session array $car = $session_array[$car_id['id']]; $heading = Heading::newHeading('h5', 'Car Details'); $content = parent::htmlAlertDiv('warning', $heading); echo parent::htmlDiv($content, 8); // Display information about the car foreach ($car as $attribute => $value) { $clean = HTML::cleanAttribute($attribute); if ($clean == 'Image') { $image = Heading::newHeading('h2', 'Image'); if (!empty($value)) { $image .= '<img src="' . $value . '" alt="image" class="img-thumbnail">'; } else { $image .= Heading::newHeading('h4', 'Not Available'); } } else { if ($clean == 'Guid') { continue; } else { $ctn .= '<b>' . $clean . '</b>: ' . $value . '<br />'; } } } $ctn .= Link::newLink('<br />Go Back', 'index.php', '_self'); $well = parent::htmlWell('lg', $ctn); echo parent::htmlDiv($image, 6); echo parent::htmlDiv($well, 6); // Footer echo parent::getFooter(); }
public function __construct() { // Header echo parent::getHeader('New Car'); $heading = Heading::newHeading('h5', 'Add a New Car'); $content = parent::htmlAlertDiv('warning', $heading); echo parent::htmlDiv($content, 8); // newInputField($type, $name, $value, $readonly, $placeholder) // I need: type, name, placeholder // newButton($type, $name, $class, $text) // I need: type, class, text $make = InputField::newInputField('text', 'make', '', '', 'Make'); $model = InputField::newInputField('text', 'model', '', '', 'Model'); $year = InputField::newInputField('text', 'year', '', '', 'Year'); $carPic = InputField::newInputField('file', 'file', '', '', 'File Input'); $submit = Button::newButton('submit', '', 'primary', 'Submit'); $form = new Form('index.php?page=addcar', 'POST'); $form->addNewInput($make); $form->addNewInput($model); $form->addNewInput($year); $form->addNewInput($carPic); $form->addNewInput($submit); $content = $form->getForm(); $content .= Link::newLink('Go Back', 'index.php', '_self'); echo parent::htmlDiv($content, 4); // Get footer echo parent::getFooter(); }
public function __construct() { // Header echo parent::getHeader('Import CSV File'); // Check if a csv file exists in the uploads folder // If so, display a table and a button to delete the file if necessary $dir = 'uploads/*.csv'; foreach (glob($dir) as $file) { // If a csv file exists on the server, process it if ($file != NULL) { $heading = Heading::newHeading('h5', 'File Being Processed'); $content = parent::htmlAlertDiv('warning', $heading); echo parent::htmlDiv($content, 8); $content = '<p><strong>' . basename($file) . '</strong>  '; $content .= '<span><a href="index.php?page=importcsv&deleteFile=' . $file . '" class="btn btn-danger btn-xs" role="button">Remove</a></span></p>'; echo parent::htmlDiv($content, 6); // Open up the file and save its content into an array $arrayCSV = array(); $pathToFile = 'uploads/' . basename($file); $handle = fopen($pathToFile, 'r'); if ($handle) { while (($data = fgetcsv($handle, 1000, ',')) != false) { $arrayCSV[] = $data; } fclose($handle); } $table = '<br /><br />'; $table .= Heading::newHeading('h3', 'This table only shows 13 columns and 200 rows'); $table .= '<br />'; $table .= CSVTable::generateCSVTable($arrayCSV); echo parent::htmlDiv($table, 12); } } // If no csv files in the uploads directory, display the form if (glob($dir) == NULL) { $heading = Heading::newHeading('h5', 'Upload a CSV file to see its content below in a table.'); $content .= parent::htmlAlertDiv('info', $heading); echo parent::htmlDiv($content, 8); // Form to upload CSV file $csvFile = InputField::newInputField('file', 'file', '', '', 'File Input'); $submit = Button::newButton('submit', '', 'primary btn-xs', 'Upload'); $form = new Form('index.php?page=importcsv', 'POST'); $form->addNewInput($csvFile); $form->addNewInput($submit); $content = $form->getForm(); echo parent::htmlDiv($content, 4); } // Footer echo parent::getFooter(); }
public function __construct($session_array = '', $car_id = '') { // Get header echo parent::getHeader('Edit Car'); // Get the proper car in the array $car = $session_array[$car_id['id']]; $content = parent::htmlAlertDiv('warning', Heading::newHeading('h5', 'Edit or delete the car below')); echo parent::htmlDiv($content, 8); // newInputField($type, $name, $value, $readonly, $placeholder) // newButton($type, $name, $class, $text) $form = new Form('index.php?page=editcar', 'POST'); foreach ($car as $attribute => $value) { $clean = HTML::cleanAttribute($attribute, 'false'); if ($clean == 'guid') { // Disable the GUID input field so it cannot be edited ${$clean} = InputField::newInputField('text', $clean, $value, 'readonly', 'ID'); $form->addNewInput(${$clean}); } else { if ($clean == 'image') { $img = Heading::newHeading('h2', 'Image'); if (!empty($value)) { $img = '<div class="thumbnail">'; $img .= '<img src="' . $value . '" alt="image">'; $img .= '</div>'; ${$clean} = InputField::newInputField('text', $clean, $value, 'readonly', 'Image Path'); $form->addNewInput(${$clean}); } else { $img .= Heading::newHeading('h4', 'Not available'); } } else { // If not a GUID input field, allow for editing ${$clean} = InputField::newInputField('text', $clean, $value); $form->addNewInput(${$clean}); } } } $carPic = InputField::newInputField('file', 'file', '', '', 'New Picture'); $save = Button::newButton('submit', 'save', 'success', 'Save'); $delete = Button::newButton('submit', 'delete', 'danger', 'Delete'); $form->addNewInput($carPic); $form->addNewInput($save); $form->addNewInput($delete); $content = $form->getForm(); $content .= Link::newLink('Go Back<br /><br />', 'index.php', '_self') . '</li></ul>'; echo parent::htmlDiv($img, 6); echo parent::htmlDiv($content, 4); // Get footer echo parent::getFooter(); }
public function __construct($session_array = '') { // Header echo parent::getHeader('Home'); // Content if (!empty($session_array)) { $heading = Heading::newHeading('h5', 'Cars Stored in Session'); $content = parent::htmlAlertDiv('warning', $heading); echo parent::htmlDiv($content, 8); $content = Table::generateTable($session_array); echo parent::htmlDiv($content, 6); } else { $heading = Heading::newHeading('h5', 'No cars stored in session to be displayed.'); $content = parent::htmlAlertDiv('danger', $heading); $heading = Heading::newHEading('h5', 'Add a new car by clicking the <strong>"Add New Car"</strong> link above.'); $content .= parent::htmlAlertDiv('info', $heading); echo parent::htmlDiv($content, 8); } // Footer echo parent::getFooter(); }