<?php
class GCargo{    

  public function __construct(){
		$filter='';
	}

    public function addFilter($stringfilter, $condition="AND"){
		$a_filter=!is_array($stringfilter)?array($stringfilter):$stringfilter;
        foreach($a_filter as $i => $columns){
            $this->filter=(empty($this->filter))?" AND %s": $condition;
            switch($stringfilter){
                case 'no_area':
                  $this->filter=sprintf($this->filter, "no_cargo LIKE ?");
                break;
            }
        }
    }

    public function listarCargo(){
        return "SELECT id_cargo as id , no_cargo as noCargo FROM tc_cargo WHERE id_area = ?";
    }   
    

    public function listarArea(){
      return "SELECT id_area , no_area FROM tc_area";
    }   

    public function lista(){
        return "SELECT id_cargo as id, no_cargo as noCargo, a.id_area as idArea , no_area as noArea FROM tc_cargo AS c INNER JOIN tc_area AS a on c.id_area = a.id_area ";
    }

    
    public function guardar(){
        return "INSERT INTO tc_cargo(no_cargo, id_area,id_cargo) VALUES (?,?,?)";
    }   

    public function modificar(){
      return "UPDATE tc_cargo SET no_cargo = ?, id_area = ?  WHERE id_cargo = ?";
    }

    public function eliminar(){
        return "DELETE FROM tc_cargo WHERE id_cargo = ?";
      }
}
?>