| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | $Rev$ | $LastChangedBy$ |
|---|
| 4 | $LastChangedDate$ |
|---|
| 5 | +-------------------------------------------------------------------------+ |
|---|
| 6 | | Copyright (c) 2004 - 2010, Kreotek LLC | |
|---|
| 7 | | All rights reserved. | |
|---|
| 8 | +-------------------------------------------------------------------------+ |
|---|
| 9 | | | |
|---|
| 10 | | Redistribution and use in source and binary forms, with or without | |
|---|
| 11 | | modification, are permitted provided that the following conditions are | |
|---|
| 12 | | met: | |
|---|
| 13 | | | |
|---|
| 14 | | - Redistributions of source code must retain the above copyright | |
|---|
| 15 | | notice, this list of conditions and the following disclaimer. | |
|---|
| 16 | | | |
|---|
| 17 | | - Redistributions in binary form must reproduce the above copyright | |
|---|
| 18 | | notice, this list of conditions and the following disclaimer in the | |
|---|
| 19 | | documentation and/or other materials provided with the distribution. | |
|---|
| 20 | | | |
|---|
| 21 | | - Neither the name of Kreotek LLC nor the names of its contributore may | |
|---|
| 22 | | be used to endorse or promote products derived from this software | |
|---|
| 23 | | without specific prior written permission. | |
|---|
| 24 | | | |
|---|
| 25 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|---|
| 26 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|---|
| 27 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
|---|
| 28 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|---|
| 29 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|---|
| 30 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|---|
| 31 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|---|
| 32 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|---|
| 33 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|---|
| 34 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|---|
| 35 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|---|
| 36 | | | |
|---|
| 37 | +-------------------------------------------------------------------------+ |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | require("../../include/session.php"); |
|---|
| 41 | require("include/tables.php"); |
|---|
| 42 | require("include/fields.php"); |
|---|
| 43 | require("include/clients.php"); |
|---|
| 44 | require("include/addresses.php"); |
|---|
| 45 | require("include/addresstorecord.php"); |
|---|
| 46 | |
|---|
| 47 | class quickView{ |
|---|
| 48 | |
|---|
| 49 | function quickView($db){ |
|---|
| 50 | |
|---|
| 51 | $this->db = $db; |
|---|
| 52 | |
|---|
| 53 | }//end method - id |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | function get($clientid){ |
|---|
| 57 | |
|---|
| 58 | $clientid = mysql_real_escape_string($clientid); |
|---|
| 59 | |
|---|
| 60 | $thetable = new clients($this->db, "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"); |
|---|
| 61 | |
|---|
| 62 | $clientRecord = $thetable->getRecord($clientid, true); |
|---|
| 63 | |
|---|
| 64 | $clientRecord["invoices"] = $this->_getInvoices($clientid); |
|---|
| 65 | $clientRecord["notes"] = $this->_getnotes($clientid); |
|---|
| 66 | |
|---|
| 67 | return $clientRecord; |
|---|
| 68 | |
|---|
| 69 | }//end method - get |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | function _getInvoices($clientid){ |
|---|
| 73 | |
|---|
| 74 | $querystatement = " |
|---|
| 75 | SELECT |
|---|
| 76 | invoices.id, |
|---|
| 77 | invoices.type, |
|---|
| 78 | if(invoices.type='Invoice',invoices.invoicedate,invoices.orderdate) as thedate, |
|---|
| 79 | totalti |
|---|
| 80 | FROM |
|---|
| 81 | invoices |
|---|
| 82 | WHERE |
|---|
| 83 | invoices.clientid = '".$clientid."' |
|---|
| 84 | ORDER BY |
|---|
| 85 | type, |
|---|
| 86 | thedate"; |
|---|
| 87 | |
|---|
| 88 | return $this->_buildRecordArray($this->db->query($querystatement)); |
|---|
| 89 | |
|---|
| 90 | }//end method - _getInvoices |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | function _getNotes($clientid){ |
|---|
| 94 | |
|---|
| 95 | $querystatement = " |
|---|
| 96 | SELECT |
|---|
| 97 | notes.id, |
|---|
| 98 | notes.type, |
|---|
| 99 | notes.subject, |
|---|
| 100 | notes.category, |
|---|
| 101 | notes.completed |
|---|
| 102 | FROM |
|---|
| 103 | notes |
|---|
| 104 | WHERE |
|---|
| 105 | notes.attachedtabledefid='tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' |
|---|
| 106 | AND notes.attachedid='".$clientid."' |
|---|
| 107 | ORDER BY |
|---|
| 108 | notes.completed, |
|---|
| 109 | notes.category, |
|---|
| 110 | notes.type, |
|---|
| 111 | notes.importance DESC, |
|---|
| 112 | notes.creationdate"; |
|---|
| 113 | |
|---|
| 114 | return $this->_buildRecordArray($this->db->query($querystatement)); |
|---|
| 115 | |
|---|
| 116 | }//end method - _getNotes |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | function _buildRecordArray($queryresult){ |
|---|
| 120 | |
|---|
| 121 | $returnArray = array(); |
|---|
| 122 | |
|---|
| 123 | while($therecord = $this->db->fetchArray($queryresult)) |
|---|
| 124 | $returnArray[] = $therecord; |
|---|
| 125 | |
|---|
| 126 | return $returnArray; |
|---|
| 127 | |
|---|
| 128 | }//end method - _buildRecordArray |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | function display($clientInfo){ |
|---|
| 132 | |
|---|
| 133 | $invoiceEditFile = getAddEditFile($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883"); |
|---|
| 134 | $noteEditFile = getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1"); |
|---|
| 135 | $clientEditFile = getAddEditFile($this->db, "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"); |
|---|
| 136 | |
|---|
| 137 | ?><div class="bodyline" id="theDetails"> |
|---|
| 138 | |
|---|
| 139 | <div id="rightSideDiv"> |
|---|
| 140 | |
|---|
| 141 | <fieldset> |
|---|
| 142 | <legend>sales</legend> |
|---|
| 143 | <ul class="recordCommands"> |
|---|
| 144 | <li class="firstToolbarItem"><a href="#" class="newRecord" onclick="addEditRecord('new','invoice','<?php echo getAddEditFile($this->db, "tbld:62fe599d-c18f-3674-9e54-b62c2d6b1883","add")?>')" title="new sales order"><span>new</span></a></li> |
|---|
| 145 | <li><a href="#" id="invoiceedit" class="editRecordDisabled" onclick="addEditRecord('edit','invoice','<?php echo $invoiceEditFile?>')" title="edit"><span>edit</span></a></li> |
|---|
| 146 | </ul> |
|---|
| 147 | <div class="recordContainers"> |
|---|
| 148 | <div id="salesTable" class="smallQueryTableHolder"> |
|---|
| 149 | <?php if(!count($clientInfo["invoices"])) {?> |
|---|
| 150 | <div class="small"><em>no records</em></div> |
|---|
| 151 | <?php } else {?> |
|---|
| 152 | <table border="0" cellpadding="0" cellspacing="0" class="smallQueryTable"> |
|---|
| 153 | <tr> |
|---|
| 154 | <th align="left">ID</th> |
|---|
| 155 | <th align="left">Type</th> |
|---|
| 156 | <th align="left">Date</th> |
|---|
| 157 | <th align="right" width="100%">Total</th> |
|---|
| 158 | </tr> |
|---|
| 159 | <?php foreach($clientInfo["invoices"] as $invoicerecord) { |
|---|
| 160 | if($invoicerecord["type"]=="VOID") |
|---|
| 161 | $invoicerecord["totalti"]="-----" |
|---|
| 162 | ?><tr onclick="selectEdit(this,<?php echo $invoicerecord["id"]?>,'invoice')" ondblclick="selectedInvoice=<?php echo $invoicerecord["id"]?>;addEditRecord('edit','invoice','<?php echo $invoiceEditFile?>')"> |
|---|
| 163 | <td><?php echo $invoicerecord["id"]?></td> |
|---|
| 164 | <td><?php echo $invoicerecord["type"]?></td> |
|---|
| 165 | <td nowrap="nowrap"><?php echo formatFromSQLDate($invoicerecord["thedate"])?></td> |
|---|
| 166 | <td align="right"><?php echo numberToCurrency($invoicerecord["totalti"])?></td> |
|---|
| 167 | </tr> |
|---|
| 168 | <?php }?></table><?php }?> |
|---|
| 169 | </div> |
|---|
| 170 | </div> |
|---|
| 171 | |
|---|
| 172 | </fieldset> |
|---|
| 173 | |
|---|
| 174 | <fieldset> |
|---|
| 175 | <legend>notes</legend> |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | <ul class="recordCommands"> |
|---|
| 179 | <li class="firstToolbarItem"><a href="#" title="new note" class="newRecord" onclick="addEditRecord('new','note','<?php echo getAddEditFile($this->db, "tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1","add")?>')"><span>new</span></a></li> |
|---|
| 180 | <li><a href="#" title="edit" id="noteedit" class="editRecordDisabled" onclick="addEditRecord('edit','note','<?php echo $noteEditFile?>')"><span>edit</span></a></li> |
|---|
| 181 | </ul> |
|---|
| 182 | <div class="recordContainers"> |
|---|
| 183 | |
|---|
| 184 | <div id="notesTable" class="smallQueryTableHolder"> |
|---|
| 185 | <?php if(!count($clientInfo["notes"])) {?> |
|---|
| 186 | <div class="small"><em>no records</em></div> |
|---|
| 187 | <?php } else {?> |
|---|
| 188 | <table border="0" cellpadding="0" cellspacing="0" class="smallQueryTable"> |
|---|
| 189 | <tr> |
|---|
| 190 | <th align="left">type</th> |
|---|
| 191 | <th align="left">category</th> |
|---|
| 192 | <th align="left" width="100%">title</th> |
|---|
| 193 | <th align="center">done</th> |
|---|
| 194 | </tr> |
|---|
| 195 | <?php foreach($clientInfo["notes"] as $noterecord) { |
|---|
| 196 | if(strlen($noterecord["subject"])>17) |
|---|
| 197 | $noterecord["subject"]=substr($noterecord["subject"],0,17)."..."; |
|---|
| 198 | if(strlen($noterecord["category"])>17) |
|---|
| 199 | $noterecord["category"]=substr($noterecord["category"],0,17)."..."; |
|---|
| 200 | ?><tr onclick="selectEdit(this,<?php echo $noterecord["id"]?>,'note')" ondblclick="selectedNote=<?php echo $noterecord["id"]?>;addEditRecord('edit','note','<?php echo $noteEditFile?>')"> |
|---|
| 201 | <td><?php echo $noterecord["type"]?></td> |
|---|
| 202 | <td><?php echo $noterecord["category"]?></td> |
|---|
| 203 | <td><?php echo $noterecord["subject"]?></td> |
|---|
| 204 | <td align="center"><?php echo booleanFormat($noterecord["completed"])?></td> |
|---|
| 205 | </tr> |
|---|
| 206 | <?php }?></table><?php }?> |
|---|
| 207 | </div> |
|---|
| 208 | </div> |
|---|
| 209 | |
|---|
| 210 | </fieldset> |
|---|
| 211 | |
|---|
| 212 | </div> |
|---|
| 213 | |
|---|
| 214 | <div id="leftSideDiv"> |
|---|
| 215 | |
|---|
| 216 | <fieldset id="crTile" class="fs<?php echo $clientInfo["type"]?>"> |
|---|
| 217 | |
|---|
| 218 | <h1> |
|---|
| 219 | <input type="hidden" id="theid" value="<?php echo $clientInfo["id"] ?>" /> |
|---|
| 220 | <input type="hidden" id="theuuid" value="<?php echo $clientInfo["uuid"] ?>" /> |
|---|
| 221 | <?php |
|---|
| 222 | if($clientInfo["company"]) |
|---|
| 223 | echo htmlQuotes($clientInfo["company"]); |
|---|
| 224 | else |
|---|
| 225 | echo htmlQuotes($clientInfo["firstname"]." ".$clientInfo["lastname"]); |
|---|
| 226 | ?> <button id="viewClientButton" type="button" title="view client" class="graphicButtons buttonInfo" onclick="addEditRecord('edit','client','<?php echo $clientEditFile?>')"><span>view client</span></button></h1> |
|---|
| 227 | |
|---|
| 228 | <?php |
|---|
| 229 | if($clientInfo["company"] && $clientInfo["firstname"] && $clientInfo["lastname"]){ |
|---|
| 230 | |
|---|
| 231 | ?><p id="crName"><?php echo htmlQuotes($clientInfo["firstname"])?> <?php echo htmlQuotes($clientInfo["lastname"])?></p><?php |
|---|
| 232 | |
|---|
| 233 | }//endif |
|---|
| 234 | ?> |
|---|
| 235 | |
|---|
| 236 | <?php |
|---|
| 237 | |
|---|
| 238 | $location = ""; |
|---|
| 239 | $location .= htmlQuotes($clientInfo["address1"]); |
|---|
| 240 | |
|---|
| 241 | if($clientInfo["address2"]) |
|---|
| 242 | $location .= "<br />".htmlQuotes($clientInfo["address2"]); |
|---|
| 243 | |
|---|
| 244 | if($clientInfo["city"] || $clientInfo["state"] || $clientInfo["postalcode"]){ |
|---|
| 245 | |
|---|
| 246 | $location .= "<br/>".htmlQuotes($clientInfo["city"]); |
|---|
| 247 | if($clientInfo["city"] && $clientInfo["state"]) |
|---|
| 248 | $location .= ", "; |
|---|
| 249 | $location .= htmlQuotes($clientInfo["state"]); |
|---|
| 250 | $location .= " ".htmlQuotes($clientInfo["postalcode"]); |
|---|
| 251 | |
|---|
| 252 | }//endif |
|---|
| 253 | |
|---|
| 254 | if($clientInfo["country"]) |
|---|
| 255 | $location .= "<br />".htmlQuotes($clientInfo["country"]); |
|---|
| 256 | |
|---|
| 257 | if($location == "") |
|---|
| 258 | $location = "unspecified location"; |
|---|
| 259 | |
|---|
| 260 | ?><p id="crLocation"><?php echo $location?></p> |
|---|
| 261 | |
|---|
| 262 | </fieldset> |
|---|
| 263 | |
|---|
| 264 | <fieldset> |
|---|
| 265 | <legend>Contact</legend> |
|---|
| 266 | <?php if($clientInfo["workphone"] || $clientInfo["homephone"] || $clientInfo["mobilephone"] || $clientInfo["otherphone"] || $clientInfo["fax"]){ ?> |
|---|
| 267 | |
|---|
| 268 | <p class="RDNames">phone</p> |
|---|
| 269 | |
|---|
| 270 | <div class="fauxP RDData"> |
|---|
| 271 | <ul> |
|---|
| 272 | <?php if($clientInfo["workphone"]){ ?> |
|---|
| 273 | <li><?php echo $clientInfo["workphone"] ?> (w)</li> |
|---|
| 274 | <?php }?> |
|---|
| 275 | |
|---|
| 276 | <?php if($clientInfo["homephone"]){ ?> |
|---|
| 277 | <li><?php echo $clientInfo["homephone"] ?> (h)</li> |
|---|
| 278 | <?php }?> |
|---|
| 279 | |
|---|
| 280 | <?php if($clientInfo["mobilephone"]){ ?> |
|---|
| 281 | <li><?php echo $clientInfo["mobilephone"] ?> (m)</li> |
|---|
| 282 | <?php }?> |
|---|
| 283 | |
|---|
| 284 | <?php if($clientInfo["otherphone"]){ ?> |
|---|
| 285 | <li><?php echo $clientInfo["otherphone"] ?> (o)</li> |
|---|
| 286 | <?php }?> |
|---|
| 287 | |
|---|
| 288 | <?php if($clientInfo["fax"]){ ?> |
|---|
| 289 | <li><?php echo $clientInfo["fax"] ?> (fax)</li> |
|---|
| 290 | <?php }?> |
|---|
| 291 | </ul> |
|---|
| 292 | </div> |
|---|
| 293 | |
|---|
| 294 | <?php }?> |
|---|
| 295 | |
|---|
| 296 | <?php if($clientInfo["email"]){ ?> |
|---|
| 297 | <p class="RDNames">e-mail</p> |
|---|
| 298 | <p class="RDData"> |
|---|
| 299 | <button type="button" class="graphicButtons buttonEmail" onclick="document.location='mailto:<?php echo $clientInfo["email"]?>'"><span>send email</span></button> |
|---|
| 300 | <a href="mailto:<?php echo $clientInfo["email"]?>"><?php echo htmlQuotes($clientInfo["email"])?></a> |
|---|
| 301 | </p> |
|---|
| 302 | <?php }?> |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | <?php if($clientInfo["webaddress"]){ ?> |
|---|
| 306 | <p class="RDNames">web site</p> |
|---|
| 307 | <p class="RDData"> |
|---|
| 308 | <button type="button" class="graphicButtons buttonWWW" onclick="window.open('<?php echo $clientInfo["webaddress"]?>')"><span>visit site</span></button> |
|---|
| 309 | <a href="<?php echo $clientInfo["webaddress"]?>" target="_blank"><?php echo htmlQuotes($clientInfo["webaddress"])?></a> |
|---|
| 310 | </p> |
|---|
| 311 | <?php }?> |
|---|
| 312 | </fieldset> |
|---|
| 313 | |
|---|
| 314 | <fieldset> |
|---|
| 315 | <legend>Details</legend> |
|---|
| 316 | |
|---|
| 317 | <?php if($clientInfo["becameclient"]){ ?> |
|---|
| 318 | <p class="RDNames">became client</p> |
|---|
| 319 | <p class="RDData"> |
|---|
| 320 | <?php echo formatVariable($clientInfo["becameclient"],"date")?> |
|---|
| 321 | </p> |
|---|
| 322 | <?php }?> |
|---|
| 323 | |
|---|
| 324 | <?php if($clientInfo["category"]){ ?> |
|---|
| 325 | <p class="RDNames">category</p> |
|---|
| 326 | <p class="RDData"> |
|---|
| 327 | <?php echo htmlQuotes($clientInfo["category"])?> |
|---|
| 328 | </p> |
|---|
| 329 | <?php }?> |
|---|
| 330 | |
|---|
| 331 | <?php if($clientInfo["leadsource"]){ ?> |
|---|
| 332 | <p class="RDNames">lead source</p> |
|---|
| 333 | <p class="RDData"> |
|---|
| 334 | <?php echo htmlQuotes($clientInfo["leadsource"])?> |
|---|
| 335 | </p> |
|---|
| 336 | <?php }?> |
|---|
| 337 | |
|---|
| 338 | <?php if($clientInfo["salesmanagerid"]){ |
|---|
| 339 | global $phpbms; ?> |
|---|
| 340 | <p class="RDNames">sales person</p> |
|---|
| 341 | <p class="RDData"> |
|---|
| 342 | <?php echo htmlQuotes($phpbms->getUserName($clientInfo["salesmanagerid"]))?> |
|---|
| 343 | </p> |
|---|
| 344 | <?php }?> |
|---|
| 345 | |
|---|
| 346 | </fieldset> |
|---|
| 347 | |
|---|
| 348 | |
|---|
| 349 | <?php if($clientInfo["comments"]){?> |
|---|
| 350 | <fieldset> |
|---|
| 351 | <legend>memo</legend> |
|---|
| 352 | <p> |
|---|
| 353 | <?php echo htmlQuotes($clientInfo["comments"])?> |
|---|
| 354 | </p> |
|---|
| 355 | </fieldset> |
|---|
| 356 | <?php }?> |
|---|
| 357 | |
|---|
| 358 | </div> |
|---|
| 359 | <p id="theclear"> </p> |
|---|
| 360 | </div> |
|---|
| 361 | <?php |
|---|
| 362 | |
|---|
| 363 | }//endMethod - display |
|---|
| 364 | |
|---|
| 365 | }//end class |
|---|
| 366 | |
|---|
| 367 | // PROCESSING ===================================================================================== |
|---|
| 368 | // ================================================================================================= |
|---|
| 369 | if(isset($_GET["id"])){ |
|---|
| 370 | |
|---|
| 371 | $quickView = new quickView($db); |
|---|
| 372 | |
|---|
| 373 | $clientInfo = $quickView->get($_GET["id"]); |
|---|
| 374 | |
|---|
| 375 | $quickView->display($clientInfo); |
|---|
| 376 | |
|---|
| 377 | }//endif - id |
|---|
| 378 | |
|---|
| 379 | ?> |
|---|