예제 #1
0
            $imagename = uniqid();
            SpoonFile::setContent(IMAGE_PATH . '/' . $imagename . '.' . $frm->getField('photo')->getExtension(), SpoonFile::getContent($frm->getField('photo')->getTempFileName()));
            //create Thumbnail
            $frm->getField('photo')->createThumbnail(IMAGE_PATH . '/' . $imagename . '_thumbnail.' . $frm->getField('photo')->getExtension(), 130, 130);
        }
        $company = "";
        for ($i = 1; $i < 6; $i++) {
            $company .= $frm->getField('company' . $i)->getValue() . ', ' . $frm->getField('registerno' . $i)->getValue() . ', ' . $frm->getField('companyno' . $i)->getValue() . ', ' . $frm->getField('companyemail' . $i)->getValue() . ', ' . $frm->getField('shareholder' . $i)->getValue() . ', ' . $frm->getField('registeraddr' . $i)->getValue() . ', ' . $frm->getField('businessaddr' . $i)->getValue();
            if ($i < 6) {
                $company .= ', ';
            }
        }
        //get values from form
        $values = array();
        for ($i = 1; $i < 6; $i++) {
            $values = array_merge($values, array('company' . $i, 'shareholder' . $i, 'registerno' . $i, 'companyno' . $i, 'companyemail' . $i, 'registeraddr' . $i, 'businessaddr' . $i));
        }
        $values = array_merge($frm->getValues(array_merge(array('form', 'submit', '_utf8'), $values)), $frm->getField('photo')->isFilled() ? array('photo' => $imagename, 'photoext' => $frm->getField('photo')->getExtension()) : array(), array("company" => $company, 'lastupdate' => time()));
        foreach ($values as $key => $value) {
            if ($value == NULL) {
                unset($values[$key]);
            }
        }
        $insert = $mysql->insert('profiles', $values);
        $tpl->assign('tooltip', isset($insert) ? 'You have successfuly create a new profile. More Action ?<br /> <a href="' . BASE_URL . '/edit.php?id=' . $insert . '">Edit</a> | <a href="' . BASE_URL . '/profile.php?id=' . $insert . '">Print</a> | <a href="' . BASE_URL . '/edit.php?id=' . $insert . '&delete=1">Delete</a> or Create a new Profile <a href="' . BASE_URL . '">here</a>.' : 'Creating new profile resulted failed.');
    }
}
if (!isset($insert)) {
    $frm->parse($tpl);
}
$tpl->display(ROOT_PATH . '/' . TEMPLATE_PATH . '/index.tpl.php');
예제 #2
0
 /**
  * Fetches all the values for this form as key/value pairs
  *
  * @param mixed[optional] $excluded Which elements should be excluded?
  * @return array
  */
 public function getValues($excluded = array('form', 'save', '_utf8'))
 {
     return parent::getValues($excluded);
 }
예제 #3
0
define('LOAD_HEADER', true);
require 'loader.php';
//create new SpoonForm
$frm = new SpoonForm('searchProfile');
//create forms elements
$frm->addTexts('file', 'case', 'name', 'ic', 'placeofbirth', 'education', 'language', 'race', 'faith', 'maritalstatus', 'nationality', 'profession', 'epf', 'banker', 'contactno', 'email', 'platesno', 'assets', 'eye', 'hair', 'skin', 'dna', 'company', 'registerno', 'companyno', 'companyemail');
$frm->addTextareas('address', 'family', 'registeraddr', 'businessaddr', 'remarks');
$frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female'));
$frm->addText('height')->setAttribute('placeholder', 'digits only');
$frm->addText('weight')->setAttribute('placeholder', 'digits only');
$frm->addDropdown('blood', array('' => '', 'O+' => 'O+', 'A+' => 'A+', 'B+' => 'B+', 'AB+' => 'AB+', 'O-' => 'O-', 'A-' => 'A-', 'B-' => 'B-', 'AB-' => 'AB-'));
$frm->addButton('submit', 'Submit');
if ($frm->isSubmitted()) {
    //generate query
    $query = 'SELECT `id`, `photo`, `file`, `case`, `name`, `ic`, `company` FROM `profiles` WHERE `status` !=  \'trash\' ';
    $value = $frm->getValues('form', 'submit', '_utf8');
    foreach ($value as $key => $value) {
        if ($value != NULL) {
            $query .= 'AND ';
            $query .= '`' . $key . '` LIKE \'%';
            $query .= (string) $value;
            $query .= '%\' ';
        }
    }
    //get results
    $query = $mysql->getRecords($query);
    if (count($query) > 0) {
        $tpl->assign('isResult', true);
        foreach ($query as $key => $value) {
            if (isset($value['photo'])) {
                $query[$key]['photo'] = '<img src="' . BASE_URL . '/images.php?id=' . $value['id'] . '&thumbnail=1" />';