<?php

include_once"base_connect.php";

switch ($part) {
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_quick_entry":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(

'drops3'=>array(
'label'=>'Business Category',
'table'=>sub_table,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>business_type,
'ref'=>'industry_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'1',
'other_id_col'=>'0',
'encoding'=>'0'),


);



$dropdowns2=array(
);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Company Name',
'fname'=>title,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'hint'=>'Business Name',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Domai Name / dotcom',
'fname'=>domain,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'addon'=>'www.',
'hint'=>'Note : Please Check Domain First',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Contact Person / Owner Name (optional)',
'fname'=>person,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'hint'=>'Business Name',
'masking'=>'off',
'required'=>'0'),

array(
'label'=>'Cell Number',
'fname'=>cell,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'hint'=>'345-8500096',
//'placeholder'=>'345-8500096',
'masking'=>$mask1,
'required'=>'1'),

/*
array(
'label'=>'Live URL',
'fname'=>'col1',
'class'=>'col-md-6',
'json'=>'1',
'json_id'=>'url_id',
'json_matching_col'=>'col1',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'hint'=>'e.g Sample Entry 1	',
'required'=>'0'),
*/


);


$integerfields=array(
);


$wysiwygfields=array(

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(
array(
'fname'=>'posted_by',
'value'=>$user_id
)

);


$update_settings=array(
'update_flag'=>"Lead Edited",
'update_ref'=>"ims_update",
'update_email'=>0
);



$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_quick_entry_alias,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/quickentries/",
'form_table'=>main_table,
'form_heading'=>"Entry",
'alias'=>"quick_lead_entry"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "update_record":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}

$dropdowns=array(

'drops3'=>array(
'label'=>'Business Category',
'table'=>sub_table,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>category_id,
'ref'=>'industry_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'1',
'other_id_col'=>'0',
'encoding'=>'0'),


);

$dropdowns2=array(


);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Title',
'fname'=>title,
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
//'hint'=>'Your Title Goes Here.',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Title',
'fname'=>domain,
'class'=>'col-md-12',
'encoding'=>'0',
'addon'=>'www.',
'format'=>'words',
//'hint'=>'Your Title Goes Here.',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Contact Person / Owner Name',
'fname'=>person,
'class'=>'col-md-6',
'encoding'=>'0',
'format'=>'words',
//'hint'=>'Business Name',
'masking'=>'off',
'required'=>'1'),

array(
'label'=>'Cell Number',
'fname'=>cell,
'class'=>'col-md-6',
'encoding'=>'0',
'format'=>'words',
'hint'=>'345-8500096',
//'placeholder'=>'345-8500096',
'masking'=>$mask1,
'required'=>'1'),

array(
'label'=>'Address',
'encoding'=>'0',
'class'=>'col-md-12',
'required'=>'1',
//'addon'=>'www.',
//'hint'=>'addon exmaple',
'fname'=>address,
//'placeholder'=>'i2dtechnolooges.com',
'masking'=>'off'
),

array(
'label'=>'Landlines (Optional)',
'encoding'=>'0',
'class'=>'col-md-6',
'required'=>'0',
//'addon'=>'www.',
//'hint'=>'addon exmaple',
'fname'=>landlines,
//'placeholder'=>'i2dtechnolooges.com',
'masking'=>'off'
),

array(
'label'=>'Facebook Link',
'encoding'=>'0',
'class'=>'col-md-6',
'required'=>'0',
'addon'=>'fb.com/',
//'hint'=>'addon exmaple',
'fname'=>facebook,
//'placeholder'=>'i2dtechnolooges.com',
'masking'=>'off'
),

array(
'label'=>'Email Address (optional)',
'encoding'=>'0',
'class'=>'col-md-6',
'required'=>'0',
//'addon'=>'fb.com/',
//'hint'=>'addon exmaple',
'fname'=>email,
//'placeholder'=>'i2dtechnolooges.com',
'masking'=>'off'
),

array(
'label'=>'Website (if Available)',
'encoding'=>'1',
'class'=>'col-md-6',
'required'=>'0',
'addon'=>'www.',
//'hint'=>'addon exmaple',
'fname'=>website,
//'placeholder'=>'i2dtechnolooges.com',
'masking'=>'off'
),

/*
array(
'label'=>'Live URL',
'fname'=>'col1',
'class'=>'col-md-6',
'json'=>'1',
'json_id'=>'url_id',
'json_matching_col'=>'col1',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'hint'=>'e.g Sample Entry 1	',
'required'=>'0'),
*/


);


$integerfields=array(
);


$wysiwygfields=array(
array(
'label'=>'Comments / Details',
'fname'=>description,
'height'=>'112',
'required'=>'0')

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(

array(
'fname'=>ref,
'value'=>'lead_entry',
)

);


$update_settings=array(
'update_flag'=>"Lead Updated",
'update_ref'=>"ims_update",
'update_email'=>0
);


if($legend=="1"){
$e_ref=routine_quick_entry_alias;
$alias_ref="quick_lead_entry";	
}
else{
$e_ref=routine_entry_alias;
$alias_ref="lead_entry";		
}


$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>$e_ref,
'table'=>main_table
);


$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/entries/",
'form_table'=>main_table,
'form_heading'=>"Entry",
'alias'=>$alias_ref
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_update":



$dropdowns=array(

'drops4'=>array(
'label'=>'Status',
'table'=>sub_table,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>updates_table_type_col,
'ref'=>'response_type',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0')
);

$textfields=array(


);


$wysiwygfields=array(
array(
'label'=>'Update Description',
'fname'=>updates_table_detail_col,
'required'=>'1'));

/////////////////////////////////////////////////////
$dated1 = date('d-m-Y H:i:s');
$dated=date( "d-m-Y H:i:s", strtotime( $dated1 )+5*60*60 );

if(isset($_SESSION['user']) && !empty($_SESSION['user'])){
$user=$_SESSION['user'];
}
else{
$user="system";	
}	
/////////////////////////////////////////////////////
////////////////////////////////////////////////////

$directfields=array(

array(
'fname'=>updates_table_lead_col,
'value'=>$id),
array(
'fname'=>updates_table_status_col,
'value'=>"Active"),
array(
'fname'=>updates_table_ref_col,
'value'=>"ims_update"),
array(
'fname'=>updates_table_posted_by_col,
'value'=>$user),
array(
'fname'=>updates_table_date_time_col,
'value'=>$dated)
);

$values=array(
'texts'=>$textfields,
'dropdowns'=>$dropdowns,
'wysiwygs'=>$wysiwygfields,
'directfields'=>$directfields,
'redirect'=>"/list/entries",
'form_table'=>updates_table,
'form_heading'=>"Update Lead",
'alias'=>"ims_update"
);
make_update($values,1,$id);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//////////////////////// CASE STARTS  ////////////////////////
case "view_lead":

if($legend=="1"){
$e_ref=routine_quick_entry_alias;
$alias_ref="quick_lead_entry";	
}
else{
$e_ref=routine_entry_alias;
$alias_ref="lead_entry";		
}




$settings=array
(
'table'=>main_table,
'child_table'=>sub_table,
'child_table_id_col'=>sub_table_id,
'child_table_title'=>sub_table_title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>$e_ref);
$arraycols=array(

'labels'=>array(
'Name',
'Department',


),

'fields'=>array(
title,
cell,
)
);


$remote_arraycols=array(

'labels'=>array(
'Industry',


),

'fields'=>array(
business_type,
)
);


$links_array=array(

'labels'=>array(
'address','email'),

'urls'=>array(
"/ty/".$id,title)
);

$parameters=array(
'heading'=>'View Record',
'settings'=>$settings,
'fields'=>$arraycols,
'remote_cols'=>$remote_arraycols,
//'links'=>$links_array,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_record_adv_with_updates_v2($parameters);

break;
/////////////////////////// CASE ENDS  ////////////////////////
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "view_proposal":

$settings=array
(
'table'=>main_table,
'child_table'=>main_table,
'child_table_id_col'=>id_col,
'child_table_title'=>title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>routine_all_alias);
$arraycols=array(

'labels'=>array(
'Registration Date',
'Domain',
'Company',
'Whatsapp Number',


),

'fields'=>array(
server_time,
domain,
company,
cell,
)
);


$random=random(4,$id);
$url=make_url($id);

$path=OFFER_PATH."/offers/proposal/".$random."/".$url."/";

$url_fields=array(
'dir'=>$path
);




$parameters=array(
'heading'=>'Proposal Details',
'settings'=>$settings,
'fields'=>$arraycols,
'url_fields'=>$url_fields,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_details_i2d($parameters);

break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_

//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_sub_category":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}


$dropdowns=array(

'drops3'=>array(
'label'=>'Choose Category',
'table'=>sub_table,
'table_title'=>sub_table_title,
'table_id_col'=>sub_table_id,
'this_table_field'=>'sec_id',
'ref'=>'category',
'remote_tbl_title_col'=>sub_table_title,
'add_new'=>'0',
'other_id_col'=>'0',
'encoding'=>'0'),


);





$dropdowns2=array(



);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Sub Category Name',
'fname'=>'title',
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),


);


$integerfields=array(
);


$wysiwygfields=array(

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(


);


$update_settings=array(
'update_flag'=>"Item Edited",
'update_ref'=>"shop_update",
'update_email'=>0
);


$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_sub_category_alias,
'table'=>sub_table
);

$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/subcategories/",
'form_table'=>sub_table,
'form_heading'=>"Sub Category",
'alias'=>"sub_category"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "add_category":

if(isset($type) && $type=="edit"){
$edit="1";
$lead_id=$id;
}
else{
$edit="0";
$lead_id="0";
}


$dropdowns=array(


);





$dropdowns2=array(



);

$mask1="'mask': '(999)-(9999999)'";
$mask2="'alias': 'numeric','digits': 2,'digitsOptional': false, 'placeholder': '0'";

$textfields=array(

array(
'label'=>'Category Name',
'fname'=>'title',
'class'=>'col-md-12',
'encoding'=>'0',
'format'=>'words',
'masking'=>'off',
'required'=>'1'),


);


$integerfields=array(
);


$wysiwygfields=array(

);

$wysiwygfields_choice=array(


);



$checkboxfields=array(
);


$timepickfields=array(
);

$directfields=array(


);


$update_settings=array(
'update_flag'=>"Item Edited",
'update_ref'=>"shop_update",
'update_email'=>0
);


$edit=array(
'edit'=>$edit,
'lead_id'=>$lead_id,
'e_ref'=>routine_category_alias,
'table'=>sub_table
);

$values=array(
'texts'=>$textfields,
'integers'=>$integerfields,
'dropdowns'=>$dropdowns,
'dropdowns2'=>$dropdowns2,
'checkboxes'=>$checkboxfields,
'timepicks'=>$timepickfields,
'wysiwygs'=>$wysiwygfields,
'wysiwygs_choice'=>$wysiwygfields_choice,
'directfields'=>$directfields,
'update_settings'=>$update_settings,
'datedfield'=>dated,
'dated_table'=>main_table,
'prefix'=>'APP-',
'redirect'=>"/list/categories/",
'form_table'=>sub_table,
'form_heading'=>"Category",
'alias'=>"category"
);

make_form($values,1,$edit);
break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "view_record":

$settings=array
(
'table'=>main_table,
'child_table'=>sub_table,
'child_table_id_col'=>sub_table_id,
'child_table_title'=>sub_table_title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>routine_entry_alias);
$arraycols=array(

'labels'=>array(
'Business Name',
'Cell',
'Owner Name',
'Available Domain',
'Address',
'email',
'Facebook',
'Website',


),

'fields'=>array(
title,
cell,
person,
domain,
address,
email,
facebook,
website,
)
);


$remote_arraycols=array(

'labels'=>array(
'Industry',


),

'fields'=>array(
business_type,
)
);


$links_array=array(

'labels'=>array(
'address','email'),

'urls'=>array(
"/ty/".$id,title)
);

$parameters=array(
'heading'=>'View Details',
'settings'=>$settings,
'fields'=>$arraycols,
'remote_cols'=>$remote_arraycols,
//'links'=>$links_array,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_details_v2($parameters);




break;

case "make_call":


if($legend=="1"){
$url="/list/quickentries/";	
}
else{
$url="/list/entries/";		
}

make_call($id,$url);


break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "view_i2d_blue_proposal":

$settings=array
(
'table'=>main_table,
'child_table'=>main_table,
'child_table_id_col'=>id_col,
'child_table_title'=>title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>routine_all_alias);
$arraycols=array(

'labels'=>array(
'Registration Date',
'Domain',
'Company',
'Whatsapp Number',


),

'fields'=>array(
server_time,
domain,
company,
cell,
)
);


$random=random(4,$id);
$url=make_url($id);

$path=OFFER_PATH."/offers/i2dblue/".$random."/".$url."/";

$url_fields=array(
'dir'=>$path
);




$parameters=array(
'heading'=>'i2d Blue Proposal Details',
'settings'=>$settings,
'product'=>'i2d Blue - Website Solution',
'fields'=>$arraycols,
'url_fields'=>$url_fields,
'btn_id'=>'sum_val',
'id'=>$id,
);



//$parameters['legend'] = $id; 


view_details_i2d($parameters);

break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_
case "view_i2d_smartshop_proposal":

$settings=array
(
'table'=>main_table,
'child_table'=>main_table,
'child_table_id_col'=>id_col,
'child_table_title'=>title,
'id_col'=>id_col,
'heading'=>'View Details',
'ref'=>routine_all_alias);
$arraycols=array(

'labels'=>array(
'Registration Date',
'Domain',
'Company',
'Whatsapp Number',


),

'fields'=>array(
server_time,
domain,
company,
cell,
)
);


$random=random(4,$id);
$url=make_url($id);

$path=OFFER_PATH."/offers/i2dsmartshop/".$random."/".$url."/";

$url_fields=array(
'dir'=>$path
);




$parameters=array(
'heading'=>'i2d Smartshop Proposal Details',
'settings'=>$settings,
'product'=>'i2d Smartshop - Online Store',
'fields'=>$arraycols,
'url_fields'=>$url_fields,
'btn_id'=>'sum_val',
'id'=>$id,
);


//$parameters['legend'] = $id; 


view_details_i2d($parameters);

break;
//+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+__+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_

default;

echo "<h2>i2d App Builder Service Views Does not Exist!</h2>";

}

/////////////////////////////////////////////////////////////////////////////
include_once"../includes/app_bottom.php";


?>