PHPDoctor


class/MultiRecord.class.php

Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html


/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/ 
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/

    /**
     * MultiRecord class
     * Using the DataObject and additional
     * method to manage multiple record forms.
     */

class MultiRecord extends DataObject {
    
    public $table = "";
    protected $primary_key = "";
    protected $prefix = "";  // Should be the same as the class name 
 
   
   function formMultiEntry() {
     if ($this->getNumRows()>0) {
        while ($this->next()) {
            $phone_form .= '';
            $phone_form .= '
'; $phone_form .= $this->getUpdateFormFields(); $e_delPhone = new Event($this->getPrefix()."->eventAjaxDelete"); $e_delPhone->addParam("id", $this->getPrimaryKeyValue()); $e_delPhone->setSecure(false); $e_delPhone->setEventControler("ajax_evctl.php"); $phone_form .= '
'; $phone_form .= ''; $phone_form .= '
'; } $phone_form .= '
'; $phone_form .= ''._('Add another').''; $e_addform = new Event($this->getPrefix()."->eventAjaxFormEntry"); $e_addform->setEventControler("ajax_evctl.php"); $e_addform->setSecure(false); $phone_form .= ' '; return $phone_form; } else { $this->setLog("\n (".$this->getPrefix().") Multiline form with no data"); $phone_form .= ''; $phone_form .= '
'; $new_phone_count = 1; $phone_form .= '
'; $phone_form .= $this->getNewFormFields($new_phone_count); $phone_form .= '
'; $phone_form .= '
'; $phone_form .= ''._('Add another').''; $e_addform = new Event($this->getPrefix()."->eventAjaxFormEntry"); $e_addform->setEventControler("ajax_evctl.php"); $e_addform->setSecure(false); $phone_form .= ' '; return $phone_form; } } /** * this method is called by the ajax_evctl.php as an event action * and return a new form entry to add a value to the phone_contact table. * * @param EventControler */ function eventAjaxFormEntry(EventControler $evctl) { $new_phone_count = $evctl->count; $form = '
'; $form .= $this->getNewFormFields($new_phone_count); $form .= '
'; $evctl->addOutputValue($form); } function eventAjaxDelete(EventControler $evctl) { //echo "Delete called".print_r($evctl); $this->delete($evctl->id); } protected function getPrefix() { return $this->prefix; } } ?>

PHPDoctor