Exemple #1
0
 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>&ensp;&ensp;';
             $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();
 }
Exemple #2
0
 public function __construct()
 {
     echo parent::htmlHeader('Login');
     $heading = Heading::newHeading('h4', '<b>Welcome!</b> Sing in or sing up below.');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     // Form
     $hp_uniq = InputField::hiddenInputField('text', 'form');
     $hp = InputField::hpInputField();
     $username = InputField::newInputField('text', 'email', 'Email');
     $password = InputField::newInputField('password', 'password', 'Password');
     $captcha = InputField::captchaInputField();
     $submit = Button::newButton('submit', 'btn-primary', 'Sing in');
     $form = new Form('index.php?page=login', 'POST');
     $form->addNewInput($hp_uniq);
     $form->addNewInput($hp);
     $form->addNewInput($username);
     $form->addNewInput($password);
     $form->addNewInput($captcha);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Paragraph::newParagraph('Not a member yet? Please sing up below!');
     $content .= Link::newLink('Sing up', 'index.php?page=signup', '_self');
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }
Exemple #3
0
 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();
 }
Exemple #4
0
 public function __construct($array = '', $carID = '')
 {
     // Get header
     echo parent::getHeader('Edit Car');
     // Get the proper car in the array
     $car = $array[$carID['id']];
     $content = parent::htmlAlertDiv('warning', Heading::newHeading('h5', 'Edit or delete the car below'));
     echo parent::htmlDiv($content, 8);
     //echo
     $form = new Form('index.php', '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');
             $form->addNewInput(${$clean});
         } else {
             // If not a GUID input field, allow for editing
             ${$clean} = InputField::newInputField('text', $clean, $value);
             $form->addNewInput(${$clean});
         }
     }
     $save = Button::newButton('submit', 'save', 'btn-success', 'Save');
     $delete = Button::newButton('submit', 'delete', 'btn-danger', 'Delete');
     $form->addNewInput($save);
     $form->addNewInput($delete);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back', 'index.php', '_self') . '</li></ul>';
     echo parent::htmlDiv($content, 4);
     // Get footer
     echo parent::getFooter();
 }
Exemple #5
0
 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();
 }
Exemple #6
0
 public function __construct($basicInfo, $detailedInfo, $salesman = false)
 {
     echo parent::htmlHeader('Car Details');
     $heading = Heading::newHeading('h4', 'Car details');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     $detailsList = Heading::newHeading('h4', 'Basic information:');
     $detailsList .= ListHTML::carDetailsList($basicInfo);
     echo parent::htmlDiv($detailsList, 6);
     $detailedList = Heading::newHeading('h4', 'Detailed information:');
     $detailedList .= ListHTML::carDetailedList($detailedInfo);
     echo parent::htmlDiv($detailedList, 6);
     // Display the form to edit a car if the user is logged in and the car belongs to the user
     if ($_SESSION['user_session'] && $salesman) {
         $cInfo = $basicInfo[0];
         $hp = InputField::hiddenInputField('text', 'form');
         $img_url = InputField::hiddenImageField($cInfo['Image']);
         $vin_number = InputField::newInputFieldEdit('text', 'vin', 'Vin Number', $cInfo['Vin'], true);
         $price = InputField::newInputFieldEdit('text', 'price', 'Price', $cInfo['Price'], false);
         $condition = InputField::newInputFieldEdit('text', 'condition', 'Condition', $cInfo['Condition'], false);
         $picture = InputField::newInputFieldEdit('file', 'file', 'File Input', 'Value', false);
         $edit = Button::newButtonEdit('submit', 'edit', 'btn-success', 'Edit');
         $delete = Button::newButtonEdit('submit', 'delete', 'btn-danger', 'Delete');
         $form = new Form('index.php?page=editcar', 'POST', false);
         $form->addNewInput($hp);
         $form->addNewInput($img_url);
         $form->addNewInput($vin_number);
         $form->addNewInput($price);
         $form->addNewInput($condition);
         $form->addNewInput($picture);
         $form->addNewInput($edit);
         $form->addNewInput($delete);
         $content = $form->getForm();
         $collapsible = parent::collapsibleDiv('Edit or Delete', $content);
         $collapsible .= '<br /><br /><br /><br /><br /><br /><br /><br />';
         echo parent::htmlDiv($collapsible, 6);
     }
     echo parent::htmlFooter();
 }
Exemple #7
0
 public function __construct()
 {
     echo parent::htmlHeader('Add New Car');
     $heading = Heading::newHeading('h4', 'Add a new car below');
     $content = parent::htmlAlertDiv('info', $heading);
     echo parent::htmlDiv($content, 8);
     // Form
     $hp = InputField::hiddenInputField('text', 'form');
     $vin_number = InputField::newInputField('text', 'vin', 'Vin Number');
     $price = InputField::newInputField('text', 'price', 'Price');
     $condition = InputField::newInputField('text', 'condition', 'Condition');
     $picture = InputField::newInputField('file', 'file', 'File Input');
     $submit = Button::newButton('submit', 'btn-primary', 'Submit');
     $form = new Form('index.php?page=addcar', 'POST', false);
     $form->addNewInput($hp);
     $form->addNewInput($vin_number);
     $form->addNewInput($price);
     $form->addNewInput($condition);
     $form->addNewInput($picture);
     $form->addNewInput($submit);
     $content = $form->getForm();
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }
Exemple #8
0
 public function __construct()
 {
     // Get header
     echo parent::getHeader('New Car');
     $content = parent::htmlAlertDiv('warning', Heading::newHeading('h5', 'Add a New Car'));
     echo parent::htmlDiv($content, 8);
     $make = InputField::newInputField('text', 'make', 'Make', '', 'Make');
     $model = InputField::newInputField('text', 'model', 'Model', '', 'Model');
     $year = InputField::newInputField('text', 'year', 'Year', '', 'Year');
     $submit = InputField::newInputField('submit', '', 'Submit');
     $form = new Form('index.php', 'POST');
     $form->addNewInput($make);
     $form->addNewInput($model);
     $form->addNewInput($year);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back', 'index.php', '_self');
     echo parent::htmlDiv($content, 4);
     // Get footer
     echo parent::getFooter();
 }
Exemple #9
0
 public function __construct()
 {
     echo parent::htmlHeader('Home');
     $heading = parent::htmlAlertDiv('info', Heading::newHeading('h4', 'Sign up below'));
     echo parent::htmlDiv($heading, 8);
     $hp_uniq = InputField::hiddenInputField('text', 'form');
     $hp = InputField::hpInputField();
     $firstname = InputField::newInputField('text', 'fname', 'First name');
     $lastname = InputField::newInputField('text', 'lname', 'Last name');
     $email = InputField::newInputField('text', 'email', 'Email');
     $password = InputField::newInputField('password', 'pass', 'Password');
     $password2 = InputField::newInputField('password', 'pass2', 'Re-enter password');
     $captcha = InputField::captchaInputField();
     $submit = Button::newButton('submit', 'btn-primary', 'Register');
     $form = new Form('index.php?page=signup', 'POST');
     $form->addNewInput($hp_uniq);
     $form->addNewInput($hp);
     $form->addNewInput($firstname);
     $form->addNewInput($lastname);
     $form->addNewInput($email);
     $form->addNewInput($password);
     $form->addNewInput($password2);
     $form->addNewInput($captcha);
     $form->addNewInput($submit);
     $content = $form->getForm();
     $content .= Link::newLink('Go Back', 'index.php', '_self');
     echo parent::htmlDiv($content, 4);
     echo parent::htmlFooter();
 }