-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions-item.php
168 lines (138 loc) · 6.5 KB
/
functions-item.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
*
*/
function update_item_location($mySforceConnection, $item_id, $new_loc_id){
$records[0] = new SObject();
$records[0]->Id = $item_id;
$records[0]->fields = array(
'TrackIT__Location__c' => $new_loc_id,
'Temporary_Location__c' => 'true'
);
$records[0]->type = 'TrackIT__Item__c';
$response = $mySforceConnection->update($records);
}
/**
*
*/
function keep_item_location($mySforceConnection, $item_id){
$records[0] = new SObject();
$records[0]->Id = $item_id;
$records[0]->fields = array(
'Temporary_Location__c
' => 'false'
);
$records[0]->type = 'TrackIT__Item__c';
$response = $mySforceConnection->update($records);
}
/**
*
*
*/
/* Query Items by Location */
function query_item_by_location($mySforceConnection, $location_id){
if($location_id == 'all'){
$query = "SELECT Name, Id, Image_for_ListView__c, TrackIT__Description__c, Alternate_Description__c, TrackIT__Location__c, TrackIT__Location__r.Name, Temporary_Location__c
FROM TrackIT__Item__c
WHERE isDeleted = false";
}else{
$query = "SELECT Name, Id, Image_for_ListView__c, TrackIT__Description__c, Alternate_Description__c, TrackIT__Location__c, TrackIT__Location__r.Name, Temporary_Location__c
FROM TrackIT__Item__c
WHERE TrackIT__Location__c = '" . $location_id . "'
AND isDeleted = false";
}
$response = $mySforceConnection->query($query);
display_items($mySforceConnection, $response, $location_id);
}
/**
*
*/
/* Main Display Items */
function display_items($mySforceConnection, $response, $location){
if('all' !== $location){
$arrayJobs = get_job_list($mySforceConnection);
$ploJobs = '';
foreach($arrayJobs as $jobId => $jobName){
$ploJobs .= "<option value='" . $jobId . "'>" . $jobName . "</option>";
}
}
$arrayLocs = get_location_list($mySforceConnection);
$ploLocs = '';
foreach($arrayLocs as $locId => $locName){
if($location != $locId){
$ploLocs .= "<option value='" . $locId . "'>" . $locName . "</option>";
}
}
foreach ($response as $record) {
$sObject = new SObject($record);
$sObject_Location = new SObject($sObject->fields->TrackIT__Location__r);
$sf = 'sObject'; // Dynamic Variable
//print_r($$sf->fields);
/*
stdClass Object ( [Name] => 0122780 [Id] => a3T1U000000dGMyUAM [Image_for_ListView__c] => https://lightning.thunderroadinc.com/inventory/uploads/20200806_173602.jpg [TrackIT__Description__c] => SDS Max Demolition Hammer [Alternate_Description__c] => [TrackIT__Location__c] => a3W1U000000ith2UAA [TrackIT__Location__r] => SObject Object ( [type] => TrackIT__Location__c [fields] => stdClass Object ( [Name] => TR020 Blue F250 Utitlity ) ) )
*/
echo "<div class='inv_record'>"; // BEGIN div.inv_record
echo "<div class='inv_name'>" . $$sf->fields->TrackIT__Description__c . "</div>";
if(!empty($$sf->fields->Alternate_Description__c)){
echo "<div class='inv_name'>" . $$sf->fields->Alternate_Description__c . "</div>";
}
echo "<div class='inv_image_container'><img class='inv_image' src='" . $$sf->fields->Image_for_ListView__c . "' /></div>";
echo "<div class='inv_quantity'> ID #: " . $sObject->fields->Name . "</div>";
// Location
if('true' == $$sf->fields->Temporary_Location__c
){
?>
<a class='btn_red_outline<?php echo ('MNGR' == $_SESSION['role']) ? " btn_keepitemlocation' href='#'" : "'"; ?> data-id='<?php echo $$sf->Id; ?>'>Temporary <?php echo ('MNGR' == $_SESSION['role']) ? ' <br />(Click to Keep)' : ''; ?></a>
<?php
}
?>
<!-- BEGIN Change location -->
<label style='font-size:20px;' class='hideRepReq' data-id='<?php echo $$sf->Id; ?>'>Move from: </label><br />
<select class='moveItemLocation hideRepReq' data-id='<?php echo $$sf->Id; ?>' >
<option value='0'><?php echo $sObject_Location->fields->Name; ?></option>
<?php echo $ploLocs ?>
</select>
<!-- END Change location -->
<!-- BEGIN Repair Request -->
<a style='display:block;' href='salesforce1://sObject/<?php echo $$sf->Id; ?>/view'><img src='img_assets/icon_request_repair.jpg' /></a>
<!-- END Repair Request -->
<?php
if('CREW' != $_SESSION['role']){
?>
<div class='openDrawerBtns' data-id='<?php echo $$sf->Id; ?>'>
<a href='#' class='openAdminDrawer btnOpenDrawer' data-id='<?php echo $$sf->Id; ?>'>⋮</a>
<!-- a href='#' class='openMoreDrawer btnOpenDrawer' data-id='<?php echo $$sf->Id; ?>'>?</!-->
</div>
<div class='admin_drawer' data-id='<?php echo $$sf->Id; ?>'>
<!-- BEGIN Change description
<input type='text'
class='changeItemAltDescription'
data-id='<?php echo $$sf->Id; ?>'
placeholder='Change Alt Description'
/>
<a href='#'
class='btn_changeItemAltDescription'
style='display:none;'
data-id='<?php echo $$sf->Id; ?>'>
Change Alt Description
</a><br />-->
<!-- END Change description -->
<a class='btn_OpenSFApp' href='salesforce1://sObject/<?php echo $$sf->Id; ?>/view'>Open in Salesforce App</a>
<!-- BEGIN Replace Photo -->
<form method="post" enctype="multipart/form-data" name="formUploadFile" class='frmReplacePicture' action="upload.php">
<label for="replPic_<?php echo $$sf->Id; ?>" class='lbl_replacePicture'>
<img src='uploads/rotate-camera-icon.png' style="display:block; margin:0 auto;"/>
Replace Picture
<input type="file" id = "replPic_<?php echo $$sf->Id; ?>" class='replacePicture' name="file" style="display:none;" data-id='<?php echo $$sf->Id; ?>' onchange="$('#loading_overlay').css('display','block'); this.form.submit();" >
</label>
<input type='hidden' name='auth' value='legit' />
<input type='hidden' name='type' value='item' />
<input type='hidden' name='id' value='<?php echo $$sf->Id; ?>' />
</form>
<!-- END Replace Photo -->
</div> <!-- END .admin_drawer -->
<?php
}
echo "</div>"; // END div.inv_record
}
}