Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ray on Oct 29, 2009 14:09
open dhtmlx forum
User Permission

hi...i have 2 question regarding security possibilities:

here is my connector cose:

function mark_timesheet($row)
    {     
    if ($row->get_value("in_note") == "Timb. non rilevata" || $row->get_value("out_note") == "Timb. non rilevata")
$row->set_row_style("font-weight:bold;color:red;");
    }
    
    $timesheet_grid = new GridConnector($res);
    $timesheet_grid->enable_log("Log/timesheet_grid_connector.log",true);
    $timesheet_grid->set_encoding("ISO-8859-1");
    $timesheet_grid->dynamic_loading(100);
    
    $timesheet_grid->event->attach("beforeRender",mark_timesheet);
    
    function timesheet_update($data)
    {
$attendance_id=$data->get_value("attendance_id");
$employee_id=$data->get_value("employee_id");
$punchin_time=$data->get_value("punchin_time");
$punchout_time=$data->get_value("punchout_time");
$in_note=$data->get_value("in_note");
$out_note=$data->get_value("out_note");
$status=$data->get_value("status");
//$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
mysql_query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' , punchin_time='{$punchin_time}' , punchout_time='{$punchout_time}' , status='{$status}' where attendance_id={$attendance_id}");
$data->success(); //if you have made custom update - mark operation as finished
}

function timesheet_delete($data)
    {
$attendance_id=$data->get_value("attendance_id");

//$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
mysql_query("DELETE FROM hs_hr_attendance where attendance_id={$attendance_id}");
$data->success(); //if you have made custom update - mark operation as finished
}
    
    function timesheet_insert($data)
    {
$attendance_id=$data->get_value("attendance_id");
$employee_id=$data->get_value("employee_id");
$punchin_time=$data->get_value("punchin_time");
$punchout_time=$data->get_value("punchout_time");
$in_note=$data->get_value("in_note");
$out_note=$data->get_value("out_note");
$status=$data->get_value("status");


mysql_query("INSERT hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' , punchin_time='{$punchin_time}' , punchout_time='{$punchout_time}' , status='{$status}' where attendance_id={$attendance_id}");
$data->success(); //if you have made custom update - mark operation as finished
}
    $timesheet_grid->event->attach("beforeUpdate","timesheet_update");
    $timesheet_grid->event->attach("beforeDelete","timesheet_delete");
    $timesheet_grid->event->attach("beforeInsert","timesheet_insert");
    
    
    $timesheet_grid->render_sql("SELECT " .
            "hs_hr_attendance.attendance_id, hs_hr_attendance.punchin_time, hs_hr_attendance.in_note, " .
            "hs_hr_attendance.punchout_time, hs_hr_attendance.out_note, " .
            "hs_hr_attendance.status, hs_hr_attendance.employee_id from hs_hr_attendance " .
            "JOIN hs_hr_employee " .
            "ON hs_hr_attendance.employee_id=hs_hr_employee.emp_number " .
            "WHERE hs_hr_employee.employee_id LIKE" ."'". $_GET["filter"] ."%" . "'".
            "ORDER BY punchin_time DESC", "attendance_id","punchin_time,in_note,punchout_time,out_note,status");
    
    
?>

1st question:

is there a possibility to enable edit function only if a cell have a certain value? pls see function mark timesheet

2nd question:

in my php script i check if a user have rights to access to a particular page with something like this:

if (!($check['team']=='Group 1') && !($check['team']=='Group 3'))
{ etc etc etc....
is there a way to use deny update function in cunjunction with php code?

Thank u
Answer posted by Stanislav (support) on Oct 30, 2009 05:36
>>is there a possibility to enable edit function only if a cell have a certain value
  function timesheet_update($data){
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note"); 
             if ($in_note != "Timb. non rilevata" && $out_note != "Timb. non rilevata") 
                          return $data->error();


>>is there a way to use deny update function in cunjunction with php code? 
You can place any custom logic in beforeUpdate handler, and block update operation from it. 

  function timesheet_update($data){
             global $check;
             if (!($check['team']=='Group 1') && !($check['team']=='Group 3'))
                 return $data->error();
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note"); 
             if ($in_note != "Timb. non rilevata" && $out_note != "Timb. non rilevata") 
                 return $data->error();


Answer posted by Stanislav (support) on Oct 30, 2009 05:37
To distinguish between sql errors and your custom rules , you can use 
           $data->invalid();
instead of 
           $data->error();

Answer posted by Ray on Nov 03, 2009 04:37
The code:
function timesheet_update($data){
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note"); 
             if ($in_note != "Timb. non rilevata" && $out_note != "Timb. non rilevata") 
                          return $data->error();


doesnt work....

seem its not able to verify this string....
"Timb. non rilevata"....how can be?
Answer posted by Stanislav (support) on Nov 03, 2009 05:53
You can try to enable the server-side logs and check the incoming data, it possible that incoming data differs from above text ( some extra whitespace or similar )
Answer posted by Ray on Nov 03, 2009 07:07
This is my code:

<script>
        var date_timesheet;
        date_timesheet = new dhtmlXGridObject('date_timesheet');
        date_timesheet.setImagePath('includes/dhtmlxSuite/dhtmlxGrid/codebase/imgs/');
        date_timesheet.setHeader("Matricola,Cognome,Nome,Orario In,Nota In,Orario Out,Nota Out,Stato");
        date_timesheet.setInitWidths("*,*,*,130,110,130,110,50")
        date_timesheet.setColTypes("ro,ro,ro,ed,coro,ed,coro,ch");
        date_timesheet.setSkin("modern")
        date_timesheet.attachHeader("#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_select_filter,#connector_text_filter,#connector_select_filter");
        date_timesheet.setColSorting("connector,connector,connector,connector,connector,connector,connector,connector")
        date_timesheet.getCombo(4).put("Entrata", "Entrata");
        date_timesheet.getCombo(6).put("Uscita", "Uscita");
        date_timesheet.init();
        date_timesheet.attachEvent("onRowSelect",viewtimesheet_note);
        date_timesheet.enableSmartRendering(true);
        date_timesheet.load("includes/DataProcessor/date_timesheet_grid_connector.php");
       
        var date_timesheet_dataprocessor = new dataProcessor("includes/DataProcessor/date_timesheet_grid_connector.php");
        date_timesheet_dataprocessor.init(date_timesheet);   
       
        date_timesheet_dataprocessor.attachEvent("onAfterUpdate",function(sid,action,tid,btag){
          if (action == "error") alert("Non sei Autorizzato a modificare questo Record, Contatta l'Amministratore di Sistema'");});
                   
        </script>

and connector:

<?php
    require_once("../dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php");
    session_start();
    $res=mysql_connect("localhost","root","sandbgroup");
    mysql_select_db("hr_mysql");

    function bold_matricola($row)
    {
        $row->set_cell_style("employee_id","font-weight:bold;");
        if ($row->get_value("in_note") == "Timb. non rilevata" || $row->get_value("out_note") == "Timb. non rilevata")
                     $row->set_row_style("font-weight:bold;color:red;");
                    
    }

    $date_timesheet_grid = new GridConnector($res);
    $date_timesheet_grid->enable_log("Log/date_timesheet_grid_connector.log",true);
    $date_timesheet_grid->set_encoding("ISO-8859-1");
    $date_timesheet_grid->dynamic_loading(100);
   
   
   
    $date_timesheet_grid->event->attach("beforeRender",bold_matricola);
   
    function date_timesheet_update($data)
    {
                           
             $attendance_id=$data->get_value("attendance_id");
             $employee_id=$data->get_value("employee_id");
             $punchin_time=$data->get_value("punchin_time");
             $punchout_time=$data->get_value("punchout_time");
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note");
             if ($in_note != "Timb. non rilevata" || $out_note != "Timb. non rilevata");
                          return $data->error();
             $status=$data->get_value("status");
             //$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
             mysql_query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' , punchin_time='{$punchin_time}' , punchout_time='{$punchout_time}' , status='{$status}' where attendance_id={$attendance_id}");
             $data->success(); //if you have made custom update - mark operation as finished
     }
   
      function date_timesheet_delete($data)
        {
           
             $attendance_id=$data->get_value("attendance_id");
            
             //$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
             mysql_query("DELETE FROM  hs_hr_attendance  where attendance_id={$attendance_id}");
             $data->success(); //if you have made custom update - mark operation as finished
         }
        
    $date_timesheet_grid->event->attach("beforeUpdate","date_timesheet_update");
    $date_timesheet_grid->event->attach("beforeDelete","date_timesheet_delete");
   
   
    //$date_timesheet_grid->access->deny("delete");
   
   
   
    $date_timesheet_grid->render_sql("SELECT" .
        "a.emp_number,a.employee_id, a.emp_lastname, a.emp_firstname," .
        "b.attendance_id ,b.punchin_time, b.in_note, b.punchout_time, b.out_note, b.status  " .
        "from hs_hr_employee a " .
        "JOIN hs_hr_attendance b " .
        "ON a.emp_number=b.employee_id " . 
        "WHERE b.punchin_time LIKE"    ."'".$_SESSION['date']."%"."'  ORDER BY b.punchin_time DESC",
        "attendance_id","employee_id, emp_lastname, emp_firstname,punchin_time,in_note,punchout_time,out_note,status");
     session_destroy();
?>
 my log says:


====================================
Log started, 03/11/2009 04:11:36
====================================

Use of undefined constant bold_matricola - assumed 'bold_matricola' at /var/www/punch1.0/includes/DataProcessor/date_timesheet_grid_connector.php line 22

SELECT DISTINCT in_note as value FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%'

SELECT DISTINCT out_note as value FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%'

SELECT a.emp_number,a.employee_id, a.emp_lastname, a.emp_firstname,b.attendance_id ,b.punchin_time, b.in_note, b.punchout_time, b.out_note, b.status FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%' ORDER BY b.punchin_time DESC LIMIT 0,100

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

SELECT COUNT(*) as DHX_COUNT  FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%'

Done in 0.167422056198s



====================================
Log started, 03/11/2009 04:11:39
====================================

Use of undefined constant bold_matricola - assumed 'bold_matricola' at /var/www/punch1.0/includes/DataProcessor/date_timesheet_grid_connector.php line 22

SELECT a.emp_number,a.employee_id, a.emp_lastname, a.emp_firstname,b.attendance_id ,b.punchin_time, b.in_note, b.punchout_time, b.out_note, b.status FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%' AND in_note LIKE '%Timb. non rilevata%' ORDER BY b.punchin_time DESC LIMIT 0,100

Undefined index:  employee_id at /var/www/punch1.0/includes/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php line 65

SELECT COUNT(*) as DHX_COUNT  FROM hs_hr_employee a JOIN hs_hr_attendance b ON a.emp_number=b.employee_id WHERE  b.punchin_time LIKE'%' AND in_note LIKE '%Timb. non rilevata%'

Done in 0.00934219360352s



====================================
Log started, 03/11/2009 04:11:41
====================================

Use of undefined constant bold_matricola - assumed 'bold_matricola' at /var/www/punch1.0/includes/DataProcessor/date_timesheet_grid_connector.php line 22

DataProcessor object initialized
2276_gr_id => 2276
2276_c0 => 600-1013
2276_c1 => ZAGO
2276_c2 => FABIANA
2276_c3 => 2009-10-14 08:13:45
2276_c4 => Entrata
2276_c5 => 2009-10-14 12:31:55
2276_c6 => Uscita
2276_c7 => 1
2276_!nativeeditor_status => updated
ids => 2276

Row data [2276]
attendance_id => 2276
employee_id => 600-1013
emp_lastname => ZAGO
emp_firstname => FABIANA
punchin_time => 2009-10-14 08:13:45
in_note => Entrata
punchout_time => 2009-10-14 12:31:55
out_note => Uscita
status => 1
!nativeeditor_status => updated

Event code for update processed

Edit operation finished
0 => action:error; sid:2276; tid:2276;

Done in 0.000880002975464s

my log doesn't show me "Timb. non rilevata" but in my grid i see it....
Answer posted by Ray on Nov 04, 2009 14:18
i discover why.....

the code:  $row->get_value("in_note") == "Timb. non rilevata" if i understand well means:
"if u want to update data with value equals to : "Timb. non rilevata" then....bla bla bla....

but my needs are:

"if in the render u will find a value different to: "Timb. non rilevata" then  return $data->error();


is it possible?

Thank u

Answer posted by Stanislav (support) on Nov 05, 2009 06:19
Dataprocessor sends data to the server side, which contains only cells from the updated row. It doesn't provide any other data, so it is not possible to check any other values in grid. 
You can add the check to client side code

date_timesheet_dataprocessor.attachEvent("onBeforeUpdate",function(){
            var exist = date_timesheet.findCell("Timb. non rilevata",false,true);
            return exists.length!=0;
})

With such code, data will be sent to server side , only if mentioned string exists somewhere in the grid. 
( you need to include ext/dhtmlxgrid_filter.js to use findCell command ) 
Answer posted by Ray on Nov 05, 2009 12:13
ok...i will try.....

thank u

Answer posted by Ray on Nov 05, 2009 12:43
maybe i cannot explain well what i'm tring to do...

my grid will contains a row that can assume only 2 value: "Entrata" or "Timb. non rilevata"...

i want that a user can edit rows that contains only "Timb. non rilevata" and in case he tries to edit rows that contain "Entrata" the system
gives him an alert like "You are not allowed to edit this cell"...

if i undertood well in the code u posted the condition means ... find in every rows in the grid at least one value that contain "Timb. non rilevata"..
my needs are: find in row u are tring to edit one value that contain "Timb. non rilevata" if it is present send an alert..if not pemitt the editing operation

 what do u think about it?
Answer posted by Ray on Nov 11, 2009 07:01
Any Update regarding?

Thank you
Answer posted by Stanislav (support) on Nov 12, 2009 10:06
>>i want that a user can edit rows that contains only "Timb. non rilevata" and in case he tries to edit rows that contain "Entrata" the system

cell level block 

mygrid.attachEvent("onEditCell",function(stage,id,ind){
        if (mygrid.cells(id,ind).getValue()=="Timb. non rilevata") return true;
        alert("not allowed");
        return false;
})

or row level block


mygrid.attachEvent("onEditCell",function(stage,id,ind){
        flag = false;
        for (var i=0; i<mygrid.getColumnsNum(); i++)
            if(mygrid.cells(id,ind).getValue()=="Timb. non rilevata") flag = true;

        if (!flag) 
             alert("not allowed");
        return flag;
})
Answer posted by Ray on Nov 12, 2009 12:43
seems to doesn't work...

when i try to edit an entire row that contain in a cell "Timb. non rilevata" its says to me always not allowed....
and when i try to edit only cell containing "Timb. non rilevata" it lets me edit but when i confirm the new value its prompts me always
no allowed....

how can i solve ?

thank u
Answer posted by Alex (support) on Nov 13, 2009 06:32

Hello, 

could you please provide the sample to reproduce the issue (grid initialization code and xml)

Answer posted by Ray on Nov 13, 2009 11:45
sure...

grid init.

<div id="employee" style="width:780px; height:250px;"></div>
       
        <script>
        var employee_grid;
        employee_grid = new dhtmlXGridObject('employee');
        employee_grid.setImagePath('../../../includes/dhtmlxSuite/dhtmlxGrid/codebase/imgs/');
        employee_grid.setHeader("Matricola,Cognome,Nome,Filiale");
        employee_grid.setInitWidths("190,190,190,190");
        employee_grid.setColTypes("ro,ro,ro,ro");
        employee_grid.setSkin("light");
        employee_grid.attachHeader("#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_select_filter");
        employee_grid.setColSorting("connector,connector,connector,connector");
        employee_grid.init();
        employee_grid.attachEvent("onRowSelect",viewtimesheet);
        employee_grid.enableSmartRendering(true);
        employee_grid.loadXML("../../../includes/DataProcessor/employee_grid_connector.php");
       
   
        var emp_dataprocessor = new dataProcessor("../../../includes/DataProcessor/employee_grid_connector.php");
        emp_dataprocessor.init(employee_grid);
        </script>

        <h4>Timbrature: (Doppio click sulla riga per modificarne i valori)</h4>

        <div id="timesheet" style="width:780px;height:250px;"></div>
       
        <br />
        <input type="button" name="delete_record" value="Elimina Record Selezionato" onclick="employee_timesheet.deleteSelectedItem()">
       
        <script>
        var employee_timesheet;
        employee_timesheet = new dhtmlXGridObject('timesheet');
        employee_timesheet.setImagePath('../../../includes/dhtmlxSuite/dhtmlxGrid/codebase/imgs/');
        employee_timesheet.setHeader("Orario In,Nota In,Orario Out,Nota Out,Stato");
        employee_timesheet.setInitWidths("*,*,*,*,*");
        employee_timesheet.setColTypes("ed,ed,ed,ed,ch");
        employee_timesheet.setSkin("modern");
        employee_timesheet.attachHeader("#connector_text_filter,#connector_select_filter,#connector_text_filter,#connector_select_filter,#connector_select_filter");
        employee_timesheet.setColSorting("str,str,str,str,connector");
       
       
        employee_timesheet.attachEvent("onEditCell",function(stage,id,ind){
        flag = false;
        for (var i=0; i<employee_timesheet.getColumnsNum(); i++)
            if(employee_timesheet.cells(id,ind).getValue()=="Timb. non rilevata") flag = true;

        if (!flag)
             alert("not allowed");
        return flag;
})
       
       
        employee_timesheet.init();
        employee_timesheet.enableSmartRendering(true);
        </script>   
       
first connector:

<?php
    require_once("../config.php");
    require_once("../dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php");

    $db_selected = mysql_select_db($mysql_db_1, $link);
   
    function bold_matricola($row)
    {
        $row->set_cell_style("employee_id","font-weight:bold;");
    }
   

    $employee_grid = new GridConnector($link);
    $employee_grid->set_encoding("ISO-8859-1");
    $employee_grid->enable_log("Log/employee_grid_connector.log",true);
    $employee_grid->dynamic_loading(100);
   
    $employee_grid->event->attach("beforeRender",bold_matricola);
       
    $employee_grid->render_sql ("SELECT  hs.loc_code, hs.loc_city, b.employee_id, b.emp_lastname, b.emp_firstname, a.emp_number " .
        "FROM hs_hr_location hs " .
        "JOIN (hs_hr_emp_locations a " .
        "JOIN hs_hr_employee  b " .
        "ON (a.emp_number=b.emp_number)) " .
        "ON (a.loc_code=hs.loc_code) " .
        "WHERE b.emp_status<>'EST009' AND b.emp_status<>'EST011'" .
        "AND (b.terminated_date LIKE" . "'" . date("Y-m") . "%" . "'"  .
        "OR b.terminated_date IS NULL)",
        "emp_number","employee_id,emp_lastname,emp_firstname,loc_city");
   
require_once("../close.php");   
?>

second connector:

<?php
    require_once("../config.php");
    require_once("../dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php");

    $db_selected = mysql_select_db($mysql_db_1, $link);
   
    function mark_timesheet($row)
    {     
        if ($row->get_value("in_note") == "Timb. non rilevata" || $row->get_value("out_note") == "Timb. non rilevata")
                  $row->set_row_style("font-weight:bold;color:red;");
    }
   
    $timesheet_grid = new GridConnector($link);
    $timesheet_grid->enable_log("Log/timesheet_grid_connector.log",true);
    $timesheet_grid->set_encoding("ISO-8859-1");
    $timesheet_grid->dynamic_loading(100);
       
    $timesheet_grid->event->attach("beforeRender",mark_timesheet);   
   
    function timesheet_update($data)
    {
             $attendance_id=$data->get_value("attendance_id");
             $employee_id=$data->get_value("employee_id");
             $punchin_time=$data->get_value("punchin_time");
             $punchout_time=$data->get_value("punchout_time");
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note");
             $status=$data->get_value("status");
            
             
             //$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
             mysql_query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' , punchin_time='{$punchin_time}' , punchout_time='{$punchout_time}' , status='{$status}' where attendance_id={$attendance_id}");
             $data->success(); //if you have made custom update - mark operation as finished
     }
    
     function timesheet_delete($data)
    {
             $attendance_id=$data->get_value("attendance_id");
            
             //$conn->sql->query("UPDATE hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' where attendance_id={$attendance_id}");
             mysql_query("DELETE FROM  hs_hr_attendance  where attendance_id={$attendance_id}");
             $data->success(); //if you have made custom update - mark operation as finished
     }
   
    function timesheet_insert($data)
    {
             $attendance_id=$data->get_value("attendance_id");
             $employee_id=$data->get_value("employee_id");
             $punchin_time=$data->get_value("punchin_time");
             $punchout_time=$data->get_value("punchout_time");
             $in_note=$data->get_value("in_note");
             $out_note=$data->get_value("out_note");
             $status=$data->get_value("status"); 
            
            
             mysql_query("INSERT hs_hr_attendance SET in_note='{$in_note}' , out_note='{$out_note}' , punchin_time='{$punchin_time}' , punchout_time='{$punchout_time}' , status='{$status}' where attendance_id={$attendance_id}");
             $data->success(); //if you have made custom update - mark operation as finished
     }
    $timesheet_grid->event->attach("beforeUpdate","timesheet_update");
    $timesheet_grid->event->attach("beforeDelete","timesheet_delete");
    $timesheet_grid->event->attach("beforeInsert","timesheet_insert");
   
   
    $timesheet_grid->render_sql("SELECT " .
            "hs_hr_attendance.attendance_id, hs_hr_attendance.punchin_time, hs_hr_attendance.in_note, " .
            "hs_hr_attendance.punchout_time, hs_hr_attendance.out_note, " .
            "hs_hr_attendance.status, hs_hr_attendance.employee_id from hs_hr_attendance " .
            "JOIN hs_hr_employee  " .
            "ON hs_hr_attendance.employee_id=hs_hr_employee.emp_number " .
            "WHERE hs_hr_employee.employee_id LIKE" ."'". $_GET["filter"] ."%" . "'".
            "AND hs_hr_attendance.status= '1' AND ( hs_hr_attendance.in_note<>'' OR hs_hr_attendance.out_note<>'') " .
            "ORDER BY punchin_time DESC", "attendance_id","punchin_time,in_note,punchout_time,out_note,status");
   
require_once("../close.php");       
?>

and log:

====================================
Log started, 13/11/2009 08:11:28
====================================

Use of undefined constant mark_timesheet - assumed 'mark_timesheet' at /var/www/hrmsoftware_bench/includes/DataProcessor/timesheet_grid_connector.php line 18

DataProcessor object initialized
4915_gr_id => 4915
4915_c0 => 2009-10-27 14:25:25
4915_c1 => Entrata
4915_c2 => 2009-10-27 23:59:59
4915_c3 => Uscita
4915_c4 => 1
4915_!nativeeditor_status => updated
ids => 4915

Row data [4915]
attendance_id => 4915
punchin_time => 2009-10-27 14:25:25
in_note => Entrata
punchout_time => 2009-10-27 23:59:59
out_note => Uscita
status => 1
!nativeeditor_status => updated

Incorrect field name used: employee_id

data
attendance_id => 4915
punchin_time => 2009-10-27 14:25:25
in_note => Entrata
punchout_time => 2009-10-27 23:59:59
out_note => Uscita
status => 1
!nativeeditor_status => updated

Event code for update processed

Edit operation finished
0 => action:updated; sid:4915; tid:4915;

Done in 0.0603079795837s

Event code for update processed

Edit operation finished
0 => action:updated; sid:4915; tid:4915;

Done in 0.0898258686066s

Event code for update processed

Edit operation finished
0 => action:updated; sid:4915; tid:4915;

Done in 0.0503029823303s

Event code for update processed

Edit operation finished
0 => action:updated; sid:4915; tid:4915;

Done in 0.0873880386353s



====================================
Log started, 13/11/2009 08:11:29
====================================

Use of undefined constant mark_timesheet - assumed 'mark_timesheet' at /var/www/hrmsoftware_bench/includes/DataProcessor/timesheet_grid_connector.php line 18

SELECT  hs_hr_attendance.attendance_id, hs_hr_attendance.punchin_time, hs_hr_attendance.in_note, hs_hr_attendance.punchout_time, hs_hr_attendance.out_note, hs_hr_attendance.status, hs_hr_attendance.employee_id FROM hs_hr_attendance JOIN hs_hr_employee  ON hs_hr_attendance.employee_id=hs_hr_employee.emp_number WHERE  hs_hr_employee.employee_id LIKE'601-1190%'AND hs_hr_attendance.status= '1' AND ( hs_hr_attendance.in_note<>'' OR hs_hr_attendance.out_note<>'') ORDER BY punchin_time DESC LIMIT 0,100

SELECT COUNT(*) as DHX_COUNT  FROM hs_hr_attendance JOIN hs_hr_employee  ON hs_hr_attendance.employee_id=hs_hr_employee.emp_number WHERE  hs_hr_employee.employee_id LIKE'601-1190%'AND hs_hr_attendance.status= '1' AND ( hs_hr_attendance.in_note<>'' OR hs_hr_attendance.out_note<>'')

Done in 0.0889308452606s

in log u can find an error ..."Use of undefined constant mark_timesheet"   why?

i've tried....the entire row cannot be modified ... only the cell "Timb. non rilevata"...but it generate anyway error "Not Allowed" ..even if
the record are updated...

what i want is to be able to modify entire row where in one of the cell that belongs to row contain "Timb. non rilevata" without alert error..

thank u






Answer posted by Alex (support) on Nov 16, 2009 06:34

There was a typo in the approach provided before. Try to use

employee_timesheet.attachEvent("onEditCell",function(stage,id,ind){
  flag = false;
  for (var i=0; i<employee_timesheet.getColumnsNum(); i++)
  if(employee_timesheet.cells(id,i).getValue()=="Timb. non rilevata") flag = true;

  if (!flag) 
  alert("not allowed");
  return flag;
})

instead of

employee_timesheet.attachEvent("onEditCell",function(stage,id,ind){
  flag = false;
  for (var i=0; i<employee_timesheet.getColumnsNum(); i++)
  if(employee_timesheet.cells(id,ind).getValue()=="Timb. non rilevata") flag = true;

  if (!flag) 
  alert("not allowed");
  return flag;
})

>> in log u can find an error ..."Use of undefined constant mark_timesheet" why?

There should be   $timesheet_grid->event->attach("beforeRender","mark_timesheet")  instead of   $timesheet_grid->event->attach("beforeRender",mark_timesheet)  


Answer posted by Ray on Nov 16, 2009 07:05
it works now in every cell of selected row....but when i change from "Timb. non rilevata" to "Uscita" the record was edited but having now value different
from Timb....etc.. it alert me "Not Allowed"....

why?
Answer posted by Alex (support) on Nov 16, 2009 08:55
>> .but when i change from "Timb. non rilevata" to "Uscita" the record was edited but having now value different from Timb....etc.. it alert me "Not Allowed"....

It is correct behaviour according to the onEditCell event handler provided before. What result do you want to achieve ?

Answer posted by Ray on Nov 16, 2009 12:27
the result should be:

i should be able to edit any cell in selected row that contain "Timb. non rilevata" value...any cell should be editable if at least one cell of selected row contains "Timb. non rilevata"...when i change the cell from "Timb. non rilevata" to another value it should permitt me to edit without any alert..
if i try to edit any cell in row that contain values different from "Timb. non rilevata" it shouldn't permitt me and give me an alert "Not Allowed".

 
Answer posted by Alex (support) on Nov 17, 2009 02:54

In this case try to add additional check

employee_timesheet.attachEvent("onEditCell",function(stage,id,ind){

   if(stage) return true;
   flag = false;
   for (var i=0; i<employee_timesheet.getColumnsNum(); i++)
   if(employee_timesheet.cells(id,i).getValue()=="Timb. non rilevata") flag = true;

   if (!flag) 
   alert("not allowed");
   return flag;
})

Answer posted by Ray on Nov 17, 2009 06:16
good.....now it works....

thank u