SugarCRM editview and quick create with out logichook

SugarCRM editview and quick create with out logichook

August 2, 2018 PHP SugarCRM 0
copy custom\modules\Opportunities\views\view.edit.php or detail.php
it will auto increment number AND ONE HTML VIEW FOR CHECK BOX AND GET VALUE
<?php
ini_set("display_errors",0);
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.edit.php');
class OpportunitiesViewEdit extends ViewEdit {
  function OpportunitiesViewEdit(){
  parent::ViewEdit();
  $this->useForSubpanel = true;
  }
   function display() {
global $db;
global $current_user;
$this->ev->process();
parent::display();
$sql = "SELECT MAX(CAST(name AS SIGNED)) AS name FROM opportunities where deleted='0'";
$query = $db->query($sql);
$res = $db->fetchByAssoc($query);
//echo $res['assignment_no'];
if(!isset($_REQUEST['record']) || $_REQUEST['record']=='')
{
if($res['name']=='')
{
echo "<script> document.getElementById('name').value=10001; </script>";
}else{
echo "<script> document.getElementById('name').value=".($res['name']+1)."; </script>";
}
}
if($this->bean->date_entered!='' && strtotime($this->bean->date_entered)<time())
{
$delay = round((time()-strtotime($this->bean->date_entered))/3600/24);
}else{
$delay = '0';
}
//$delay = '0';
echo "<script> document.getElementById('delay_c').value='".$delay."';$('#delay_c').attr('readonly', true); </script>";
$tut = array();
              //  echo $this->bean->allocated_tutors_c;exit;
if(isset($this->bean->allocated_tutors_c) && $this->bean->allocated_tutors_c!='')
{
$tuts = $this->bean->allocated_tutors_c ;
$tut = explode(',',$tuts);
$tutors = array();
foreach($tut as $t)
{
 $sql = "SELECT * FROM `contacts` WHERE `id`='$t' and deleted=0 order by first_name asc";
                          $result = $db->query($sql);
 $rowc = $db->fetchByAssoc($result );
$tutors[] = $rowc['first_name']." ".$rowc['last_name'];
}
echo "<script> document.getElementById('aTuts').value='".implode(', ', $tutors)."'; </script>";
}
echo "<script> document.getElementById('aTuts').innerHTML='".implode(', ', $tutors)."'; </script>";
$tutListOp = '<table border="0" bordercolor="#999999" bordercolordark="#999999" bordercolorlight="#999999" cellspacing="2" style="font-family:Verdana, Geneva, sans-serif; color:#333333; font-size:11px;"><tr style="background-color:#999999; border: solid 1px #999999;"><td></td><td style="font-weight:bold;">Name   </td><td style="font-weight:bold;">Status    </td><td style="font-weight:bold;">NRIC</td><td style="font-weight:bold;">Contact Number </td></tr>  ';
//$sql = "SELECT * FROM `contacts`  WHERE `deleted`='0'";
$sql ="SELECT contacts.*, contacts_cstm.* FROM `contacts` join contacts_cstm ON contacts.id = contacts_cstm.id_c WHERE `deleted`='0' and status_c != 'blacklisted'";
$query = $db->query($sql);
while($res = $db->fetchByAssoc($query))
{
if(in_array($res['id'],$tut))
{
$checked = 'checked="checked"';
}else{
$checked = '';
}
if($res['status_c'] =='new'){
$statusNew ='New';
}else if($res['status_c']=='verified_nric_only'){
$statusNew ='Verified (NRIC Only)';
}else if($res['status_c']=='Verified_certs_only'){
$statusNew ='Verified (Certs Only)';
}else if($res['status_c']=='verified_nric_certs'){
$statusNew ='Verified (NRIC & Certs)';
}
$tutListOp.="<tr><td><input type=\"checkbox\" name=\"tut_id[]\" id=\"tut_id\" value=\"".$res['id']."_".$res['first_name']."\" ".$checked." onclick=\"addTutor()\"></td><td>".$res['first_name']."</td><td >".$statusNew."</td>           <td>".$res['nric_c']."</td> <td>".$res['contact_no_c']."</td></tr>";
}
$tutListOp.= "</table><table><tr><td><a href=\"javascript:void(0)\" onclick=\"hide()\">Close</a></td></tr></table>";
echo '<script>document.getElementById(\'tutLists\').innerHTML=\''.$tutListOp.'\'; </script>';
//$dateformat = $current_user->getPreference('datef');
}
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *