ACC SHELL

Path : /srv/www/vhosts/profias/inc/admin/
File Upload :
Current File : /srv/www/vhosts/profias/inc/admin/date.php

<?php

  class Date extends AdminItem
  {
    
    function Date($args)
    {
      $this->setBasicParametres($args);
      
   }
  
  
  

    function getFormParams($admin, &$form)
    {
    
      if ('0000-00-00'==$admin->dataRow[$this->formName])
      {
        //die();
        $form->default[$this->formName]='';
      }
    
      $result=array(
        'type'=>'text',
        'name'=>$this->formName,
        'value'=>$this->default,
        'reg'=>$this->reg,
        'css_id'=>$this->id.$this->formName,
        'css_class'=>$this->class,
        'spec'=>$this->spec.' onfocus="calendarDate('.date('m', time()).', '.date('Y', time()).', \''.$this->id.$this->formName.'\');"',
        'label'=>$this->name,
        'label_id'=>$this->labelId,
        'label_class'=>$this->labelClass,
        'table'=>$admin->table,
      );

    
      return array($result);
    }



// ----------------------------------------------------------------------------------------------------------------------------

  // vypis
  function select($admin)
  {
    if (TRUE==$this->table)
    {
      $table=$this->table;
    }
    else
    {
      $table=$admin->table.'s';
    }
  
    $result=array(
      'fields'=>'DATE_FORMAT('.$table.'.'.$this->field.', \'%d. %m. %Y\') AS '.$this->formName,
    );
      
    return $result;
  }
  
      
// ----------------------------------------------------------------------------------------------------------------------------

  // vypis
  function getList($admin)
  {
    if (TRUE==$this->table)
    {
      $table=$this->table;
    }
    else
    {
      $table=$admin->table.'s';
    }
  
    $result=array(
      'fields'=>'DATE_FORMAT('.$table.'.'.$this->field.', \'%d. %m. %Y\') AS '.$this->formName,
    );
      
      return $result;
  }
    
    
// ----------------------------------------------------------------------------------------------------------------------------
    
    function getInsertParams($admin)
    {
    
      $tmp=explode('.', $_POST[$this->formName]);

      if (TRUE==checkdate((int)$tmp[1], (int)$tmp[0], (int)$tmp[2]))
      {
        $result=array(
          'table'=>$admin->table.'s',
          'field'=>$this->field,
          'value'=>(int)$tmp[2].'-'.(int)$tmp[1].'-'.(int)$tmp[0],
        );
      } 
      else
      {
        $result=array(
          'table'=>$admin->table.'s',
          'field'=>$this->field,
          'value'=>'',
        );
      }     

      if (TRUE==$this->table)
      {
        $result['table']=$this->table;
      }
      return array($result);

    }    


  }


?>

ACC SHELL 2018