Multiple Selection

Add the option to select multiple rows and take an action.

In all table views, we can add a select row option that will be displayed as the first column of the table.

To enable this feature we simply need to use the variable $multiselect and set to true if we only want a select and delete option,for this feature to work, we must look at the database structure and make sure that all foreign keys are set to on delete cascade.

$multiselect = true;

To disable MULTIPLE DELETE, then we need to use $multiselect as an array and add 'DEL' = false or you can setup your own DEL option.

We can add more options other than delete, but they need to be programmed independently. 

Another pre-configured option is the "COPY_FIRST" feature, this will allow us to select multiple rows and it will select the values fo the first row to all the other selected.

 

$multiselect = array(
   'DEL' => false,
   'COPY_FIRST'=>array(
      'icon' => '<i class="fa-solid fa-copy"></i>',   //optional, fa-solid fa-copy by default
      'columns_to_copy' => 'NOTES, DESCRIPTION, CURRENCY, STATUS ',  //these are the column names from the database
      'column_headers' => 'Notes,Description,Currency,Status'  //these are the table header names used to give a title to the button and to notify on the "confirm" JS notification.
   )
);
 
To create other buttons we need the following BASIC configuration (Pending to be updated)

Required (BASIC):

$multiselect = array(
   'DEL' => true / false, //optional (DEL array by default)
   'NAME'=>array(
      'icon' => '<i>FONTAWESOME ICON</i> or <img/>',
      'id' => 'element_id',
      'type' => 'form / ajax'
​   )
);
 
Other optional (BASIC): (Pending to be updated)
 
$multiselect = array(
   'DEL' => array( /* Your own DEL options*/ ), //overwriting the default DEL
   'NAME'=>array(
      'icon' => '<i>FONTAWESOME ICON</i> or <img/> or HTML text',
      'id' => 'element_id',
      'type' => 'form / ajax',
      'title' => 'mouse over title', //optional
      'confirm' => 'Do you want to do the action?', //optional, default: executed immediately (not recommended)
      'message' => 'Selection executed successfully', //optional, default message
      'dbtable' => $dbtable, //optional, $dbtable is used as default
      'idfield' => $idfield //optional, $idfieldis used as default
   )
);

 

After setting up our basic configuration, each multiselect can and must be of one of the following 3 types:

 

KAS_FORM (Pending to be updated)

No action or method is required, this is the type of forms used all across KAS, and the system will take care of everything, dbaction is required and the case needs to be setup in your theme/db_actions.php.

NOTE: This following dbactions are already reserved and cannot be used: INSERT, UPDATE, DELETE, DELETE_SELECTION, SORT, LIVE, AJAX_INSERT, REMOVEIMAGE

In the following example, lets assume a review system, where we want to approve a bunch of reviews at the same time:

$multiselect = array(
   'APPROVE'=>array(
      'icon' => '<i class="fas fa-thumbs-up"></i>',
      'id' => 'approve_all',
      'type' => 'form',
      'title' => translate(array('en:Approve All','es:Aprobar Todas')),
      'confirm' => translate(array('en:Approve All Selected?','es:Aprobar todas las seleccionadas?')),
      'message' => translate(array('en:All were approved successfully','es:Todas han sido aprobadas')),
      'form_class' => 'KAS_FORM', //REQUIRED
      'dbaction'  => 'APPROVE_SELECTED', //REQUIRED for KAS_FORM
      'nexturl'  => $self_url, //OPTIONAL $self_url as default
​   )
);

Then inside theme/db_actions.php the code would look something like this, all the id's selected are sent encrypted with the variable $idvalue, also, note that $dbresult_error will show an error to the user if the query fails:

<?php
switch($dbaction){
   case 'APPROVE_SELECTED':
      $select_ids = explode(",",$idvalue);
      foreach($select_ids as $sel_id){
         $this_sel_ID = $encryption->decrypt($sel_id);
         $query = "UPDATE $dbtable SET APPROVE= 1 WHERE $idfield = $this_sel_ID";
         $dbresult_approve = $connection->new_query($query, false, true);
         if($dbresult_approve->getErrorNo() !== null){
            $dbresult_error = $dbresult_approve->getError();
            break;
         }
      }
   break;
}
?>

Regular FORM submit to a specific page

 

 

AJAX (Pending to be updated)

 

 

'icon' => '<i class="fas fa-trash-alt"></i>',
'id' => 'del',
'title' => 'Delete',
'confirm' => "Do you want to delete all selected items? This action cannot be undone",
'message' => "Selected items deleted successfully",
 
 
'dbtable' => '<?= $dbtable ?>',
'idfield' => '<?= $idfield ?>',
 
'type' => "form"
'nexturl' => '<?= $self_url ?>',
'form_class' => 'KAS_FORM',
'form_method' => 'post',
'form_action' => ''
 
'dbaction' => 'DELETE_SELECTION', //for KAS_FORM only
 
'type' => "ajax"
'url' => ''
'ajax_action' => '',
'reload' => 'true / false',
Get a Quote

Get a Quote