Пример #1
0
 public function echoContent()
 {
     echo '<div data-role="content">';
     $list = new ListObject(false, null, 'data-filter="true" class="clients-list"');
     // setup query statement
     $stmt = "SELECT `clients`.`id` AS 'client_id'," . "`contacts`.`name` AS 'client_name'," . "CONCAT_WS(' ',`first_name`,`middle_name`,`suffix`) AS 'first_names', " . "`balance`,`open_cases` " . 'FROM `clients` ' . 'JOIN `contacts` ON `clients`.`contact_id`=`contacts`.`id` ';
     if ($this->status == '/open') {
         $stmt .= 'WHERE `open_cases`>0 ';
     } elseif ($this->status == '/closed') {
         $stmt .= 'WHERE `open_cases`=0 ';
     }
     if ($this->sort == '/balance') {
         $stmt .= 'ORDER BY `balance` DESC ';
     } elseif ($this->sort == '/paid') {
         $stmt .= 'ORDER BY `last_payment` ';
     } else {
         $stmt .= 'ORDER BY `contacts`.`name` ';
     }
     $sth = $this->db->prepare($stmt);
     $sth->execute();
     if ($sth->rowCount()) {
         while ($row = $sth->fetch()) {
             $title = $row['client_name'];
             $title .= $row['first_names'] ? ', ' . $row['first_names'] : '';
             $item = new ListItem($title, $this->domain . 'client/' . $row['client_id'], '/css/fugue/user.png', 'class="mini-item" data-mini="true" data-icon="false"', 'target="_blank"');
             $open_cases = $row['open_cases'] == 1 ? '1 open case.' : $row['open_cases'] . ' open cases.';
             $balance = $row['balance'] > 0 ? '$' . $row['balance'] : null;
             if ($balance) {
                 $open_cases .= ' ' . $balance;
             }
             $item->setRightText($open_cases);
             $list->addListItem($item);
         }
     } else {
         $list->addText('No clients.');
     }
     $list->echoList();
     echo '</div>';
 }
Пример #2
0
 public function listAddresses($contact_id, $child_name, $child_id)
 {
     $list = new ListObject(true, null, 'class="item-list"');
     $list->addHeading('Addresses', 'New', $this->domain . $child_name . '/' . $child_id . '/' . $contact_id . '/address/new');
     $sthx = $this->db->prepare("SELECT con_addresses.abbr,`primary`,`street`,`type`,`foreign`, " . "`con_addresses`.`id` AS 'addr_id', " . "CONCAT(`loc_cities`.`name`,', ',`loc_states`.`abbr`,' ',`zip`) AS 'city_state' " . 'FROM `contacts` ' . 'JOIN `con_addresses` ON `contacts`.`id`=`con_addresses`.`contact_id` ' . 'LEFT OUTER JOIN `loc_cities` ON `con_addresses`.`city_id`=`loc_cities`.`id` ' . 'LEFT OUTER JOIN `loc_states` ON `loc_cities`.`state_id`=`loc_states`.`id` ' . 'WHERE `contact_id`=? ' . 'ORDER BY `con_addresses`.`primary` DESC,`con_addresses`.`created` DESC ');
     $sthx->execute(array($contact_id));
     if ($sthx->rowCount()) {
         while ($rowx = $sthx->fetch()) {
             $str_arr = explode(PHP_EOL, $rowx['street']);
             $item = new ListItem($str_arr[0], $this->domain . $child_name . '/' . $child_id . '/' . $contact_id . '/address/' . $rowx['addr_id'] . '/edit', '/css/fugue/card-address.png', 'class="mini-item"');
             for ($idx = 1; $idx < count($str_arr); $idx++) {
                 $item->addSubItem($str_arr[$idx]);
             }
             if ($rowx['city_state']) {
                 $item->addSubitem($rowx['city_state']);
             } else {
                 $item->addSubitem($rowx['foreign']);
             }
             $right = $rowx['abbr'] ? $rowx['abbr'] : $rowx['type'];
             //if ($rowx['primary']) $right = 'Primary: '.$right;
             if ($rowx['primary']) {
                 $right .= '  (primary)';
             }
             $item->setRightText($right);
             if ($rowx['ext']) {
                 $item->addSubItem($rowx['ext']);
             }
             $list->addListItem($item);
         }
     } else {
         $list->addText('No addresses.');
     }
     $list->echoList();
 }
Пример #3
0
 public function echoFolderContents()
 {
     $list = new ListObject(false, null, ' data-mini="true" class="item-list folder-list nomargin" data-split-theme="d" data-theme="d"');
     $subitems = false;
     // folders
     $sth = $this->db->prepare('SELECT id,subitems,name FROM folders WHERE folder_id=? ORDER BY name');
     $sth->execute(array($this->id));
     //if ($sth->rowCount()) $list->addHeading('Folders');
     while ($row = $sth->fetch()) {
         $subitems = true;
         $item = new ListItem($row['name'], $this->domain . 'folder/' . $row['id'], '/css/fugue/folder-open.png', 'data-icon="false" data-mini="true"');
         if ($row['subitems'] > 0) {
             $item->setRightText($row['subitems']);
         }
         //$item->unsetBold();
         $list->addListItem($item);
     }
     // upcoming events & tasks
     /*
      * show all overdue tasks
      * show all events/tasks for today & future ordered by date, time
      * ...
      * show passed events
      * show completed tasks
      */
     $today = new DateTime();
     $today_time = strtotime($today->format('Y-m-d'));
     $event_ids = array();
     $sth = $this->db->prepare('SELECT table_name,id,name, ' . '`date`, ' . "DATE_FORMAT(`date`, '%b %e') AS 'date_format', " . "TIME_FORMAT(`time`, '%l:%i %p') AS 'time_format' " . "FROM `calendar` WHERE folder_id=?");
     //$sth->execute(array($this->id,$today->format('Y-m-d')));
     $sth->execute(array($this->id));
     if ($sth->rowCount()) {
         $subitems = true;
         $list->addHeading('Calendar & Tasks');
     }
     while ($row = $sth->fetch()) {
         /*
                     $this_date = new DateTime($row['date']);
                     $diff = $today->diff($this_date);
                     $day_diff = (int) $diff->format('%r%a');
                     $time = $row['time_format'] ? strtolower($row['time_format']) : null;
         */
         $this_time = strtotime($row['date']);
         $day_diff = floor(($this_time - $today_time) / 3600 / 24);
         if ($row['table_name'] == 'tasks') {
             // task
             $class = 'folder-task';
             $countdown = $row['date_format'] . ' - ';
             if ($day_diff < 0) {
                 // task is overdue
                 $class .= ' folder-task-overdue';
                 $countdown .= abs($day_diff) . ' days ago';
                 //$countdown = $diff->format('%d') . ' days ago';
             } elseif ($day_diff == 0) {
                 // task is today
                 $class .= ' folder-task-1';
                 $countdown .= 'Today';
                 $countdown .= $row['time_format'] ? ' ' . $row['time_format'] : '';
             } elseif ($day_diff == 1) {
                 $class .= ' folder-task-2';
                 $countdown .= 'Tomorrow';
                 $countdown .= $row['time_format'] ? ' ' . $row['time_format'] : '';
             } else {
                 // event is in the future
                 $countdown .= $day_diff . ' days';
             }
             $item = new ListItem($row['name'], $this->domain . 'task/' . $row['id'] . '/edit', '/css/fugue/tick.png', ' class="' . $class . '" data-icon="false" data-mini="true"');
             $item->setRightText($countdown);
             $list->addListItem($item);
             $subitems = true;
         } else {
             $success = false;
             if ($day_diff > -1) {
                 if ($row['table_name'] == 'events') {
                     $success = true;
                     $event_ids[$row['id']] = 1;
                 } else {
                     if (!isset($event_ids[$row['id']])) {
                         $event_ids[$row['id']] = 1;
                         $success = true;
                     }
                 }
             }
             if ($success) {
                 // event
                 $class = 'folder-event';
                 $countdown = $row['date_format'] . ' - ';
                 if ($day_diff == 0) {
                     // event is today
                     $class .= ' folder-event-1';
                     $countdown .= 'Today';
                     $countdown .= $row['time_format'] ? ' ' . $row['time_format'] : '';
                 } elseif ($day_diff == 1) {
                     $class .= ' folder-event-2';
                     $countdown .= 'Tomorrow';
                     $countdown .= $row['time_format'] ? ' ' . $row['time_format'] : '';
                 } else {
                     // event is in the future
                     $countdown .= $day_diff . ' days';
                 }
                 $item = new ListItem($row['name'], $this->domain . 'event/' . $row['id'] . '/edit', '/css/fugue/calendar-month.png', ' class="' . $class . '" data-icon="false" data-mini="true"');
                 $item->setRightText($countdown);
                 $list->addListItem($item);
             }
         }
     }
     // tasks with no date and a priority
     $sth = $this->db->prepare('SELECT id,name,priority ' . 'FROM `tasks` WHERE `folder_id`=? AND `date` IS NULL ' . 'AND `complete` IS NULL AND `priority` IS NOT NULL ' . 'ORDER BY `priority`,`name` ');
     $sth->execute(array($this->id));
     while ($row = $sth->fetch()) {
         $subitems = true;
         $class = 'folder-task folder-task-' . $row['priority'];
         $item = new ListItem($row['name'], $this->domain . 'task/' . $row['id'] . '/edit', '/css/fugue/tick.png', ' class="' . $class . '" data-icon="false" data-mini="true"');
         if ($row['priority']) {
             $item->setRightText($row['priority']);
         }
         $list->addListItem($item);
     }
     // tasks with no date and no priority
     $sth = $this->db->prepare('SELECT id,name ' . 'FROM `tasks` WHERE `folder_id`=? AND `date` IS NULL ' . 'AND `complete` IS NULL AND `priority` IS NULL ' . 'ORDER BY `name` ');
     $sth->execute(array($this->id));
     while ($row = $sth->fetch()) {
         $subitems = true;
         $item = new ListItem($row['name'], $this->domain . 'task/' . $row['id'] . '/edit', '/css/fugue/tick.png', 'class="folder-task" data-icon="false" data-mini="true"');
         $list->addListItem($item);
     }
     // notes
     $sth = $this->db->prepare('SELECT id,name ' . 'FROM `notes` WHERE `folder_id`=? ' . 'ORDER BY `name` ');
     $sth->execute(array($this->id));
     if ($sth->rowCount()) {
         $list->addHeading('Notes');
     }
     while ($row = $sth->fetch()) {
         $subitems = true;
         $link = $this->domain . 'note/' . $row['id'];
         $item = new ListItem($row['name'], $link, '/css/fugue/notebook-sticky-note.png', 'data-icon="false" data-mini="true"');
         $list->addListItem($item);
     }
     // files
     $sth = $this->db->prepare('SELECT id,name,path ' . 'FROM `files` WHERE `folder_id`=? ' . 'ORDER BY `name` ');
     $sth->execute(array($this->id));
     if ($sth->rowCount()) {
         $list->addHeading('Files');
     }
     while ($row = $sth->fetch()) {
         $subitems = true;
         $item = new ListItem($row['name'], $this->domain . 'file/' . $row['id'], '/css/fugue/disk-black.png', 'data-icon="false" data-mini="true"');
         $list->addListItem($item);
     }
     // bill
     $sth = $this->db->prepare('SELECT id,amount,`type`, ' . "DATE_FORMAT(`date`, '%b %e, %Y') AS 'date_format' " . 'FROM `client_trans` WHERE `folder_id`=? ' . 'ORDER BY `date` ');
     $sth->execute(array($this->id));
     if ($sth->rowCount()) {
         $sthx = $this->db->prepare('SELECT balance FROM folders WHERE id=?');
         $sthx->execute(array($this->id));
         $rowx = $sthx->fetch();
         $title = 'Bill';
         if ($rowx['balance']) {
             $title .= ' balance: $' . $rowx['balance'];
         }
         $list->addHeading($title);
     }
     while ($row = $sth->fetch()) {
         $subitems = true;
         $icon;
         $title;
         switch ($row['type']) {
             case 'fee':
                 $title = 'Fee charged: $' . $row['amount'];
                 $icon = '/css/fugue/money--minus.png';
                 break;
             case 'pay':
                 $icon = '/css/fugue/money--plus.png';
                 $title = 'Payment: $' . $row['amount'];
                 break;
             case 'trust':
                 $icon = '/css/fugue/money--exclamation.png';
                 $title = 'Trust payment: $' . $row['amount'];
                 break;
         }
         $item = new ListItem($title, $this->domain . 'bill/' . $row['id'] . '/edit', $icon, 'data-icon="false" data-mini="true"');
         $item->setRightText($row['cr_format']);
         $list->addListItem($item);
     }
     // passed events
     $events = false;
     $sth = $this->db->prepare('SELECT id,name, ' . '`date`, ' . "DATE_FORMAT(`date`, '%b %e, %Y') AS 'date_format', " . "TIME_FORMAT(`time`, '%l:%i %p') AS 'time_format' " . "FROM `events` WHERE folder_id=? ORDER BY `date` DESC");
     //$sth->execute(array($this->id,$today->format('Y-m-d')));
     $sth->execute(array($this->id));
     while ($row = $sth->fetch()) {
         $subitems = true;
         $this_time = strtotime($row['date']);
         $day_diff = floor(($this_time - $today_time) / 3600 / 24);
         if ($day_diff < 0 && !isset($event_ids[$row['id']])) {
             if (!$events) {
                 $list->addHeading('Completed');
                 $events = true;
             }
             $item = new ListItem($row['name'], $this->domain . 'event/' . $row['id'] . '/edit', '/css/fugue/calendar-month.png', ' class="' . $class . '" data-icon="false" data-mini="true"');
             $item->setRightText($row['date_format']);
             $list->addListItem($item);
         }
     }
     // completed tasks
     $sth = $this->db->prepare('SELECT id,name,complete ' . 'FROM `tasks` WHERE `folder_id`=? AND `complete` IS NOT NULL ORDER BY `complete` DESC');
     $sth->execute(array($this->id));
     while ($row = $sth->fetch()) {
         if (!$events) {
             $list->addHeading('Completed');
             $events = true;
         }
         $subitems = true;
         $comp_timestamp = strtotime($row['complete'] . ' UTC');
         $local_date = date('M j, Y', $comp_timestamp);
         $item = new ListItem($row['name'], $this->domain . 'task/' . $row['id'] . '/edit', '/css/fugue/tick.png', ' class="folderitem-complete" data-icon="false" data-mini="true"');
         $item->setRightText($local_date);
         $list->addListItem($item);
     }
     if (!$subitems) {
         $list->addText('Nothing in this folder.');
     }
     $list->echoList();
 }
Пример #4
0
 public function echoClient()
 {
     $sth = $this->db->prepare("SELECT `contact_id`,`ssn`,`aka`,`dba`, " . "DATE_FORMAT(`dob`, '%c-%e-%Y') AS 'dob_format' " . 'FROM `clients` ' . 'JOIN `contacts` ON `clients`.`contact_id`=`contacts`.`id` ' . 'WHERE `clients`.`id`=?');
     $sth->execute(array($this->id));
     if ($row = $sth->fetch()) {
         $this->contact_id = $row['contact_id'];
         // client info
         $list = new ListObject(true);
         $item = new ListItem($this->full_name, $this->domain . 'client/' . $this->id . '/edit', '/css/fugue/user.png', 'class="mini-item"');
         if ($row['dob_format']) {
             $item->addSubItem('DOB: ' . $row['dob_format']);
         }
         if ($row['ssn']) {
             $item->addSubItem('SSN: ' . $row['ssn']);
         }
         if ($row['aka']) {
             $item->addSubItem($paras[] = 'AKA: ' . $row['aka']);
         }
         if ($row['dba']) {
             $item->addSubItem($paras[] = 'DBA: ' . $row['dba']);
         }
         //$list->addItem($this->full_name, $this->domain.'client/'.$this->id.'/edit', '/css/fugue/user.png', $paras);
         $list->addListItem($item);
         $list->echoList();
         // cases
         $list = new ListObject(true, 'info', 'data-split-theme="c" class="case-list"');
         $list->addHeading('Cases', '<u>N</u>ew', $this->domain . 'case/new/' . $this->id);
         $sthx = $this->db->prepare("SELECT `closed`,`folders`.`id` AS 'folder_id'," . "`balance`,`docket`, " . "`employees`.`name` AS 'atty_name'," . "DATE_FORMAT(`opened`, '%c-%e-%y') AS 'open_format', " . "`folders`.`name` AS 'folder_name', " . "`case_types`.`name` AS 'type_name' " . 'FROM `folders` ' . 'LEFT OUTER JOIN `case_types` ON `folders`.`type_id`=`case_types`.`id` ' . 'JOIN `employees` ON `folders`.`emp_id`=`employees`.`id` ' . 'WHERE `client_id`=? AND `folders`.`folder_id` IS NULL ORDER BY `folders`.`opened` DESC');
         $sthx->execute(array($this->id));
         if ($sthx->rowCount()) {
             while ($rowx = $sthx->fetch()) {
                 $item = new ListItem($rowx['folder_name'], $this->domain . 'folder/' . $rowx['folder_id'], '/css/fugue/inbox-document-text.png', 'class="mini-item"');
                 $item->addSplit($this->domain . 'case/' . $rowx['folder_id'] . '/edit');
                 $item->setRightText($rowx['open_format']);
                 $subtext = '';
                 if ($rowx['type_name']) {
                     $subtext .= $rowx['docket'] ? $rowx['docket'] . ' - ' : '';
                     $subtext .= $rowx['type_name'] . ' case. ';
                 }
                 $subtext .= 'Attorney: ' . $rowx['atty_name'] . '. ';
                 if ($rowx['closed']) {
                     $subtext .= 'Case closed. ';
                 }
                 if ($rowx['fee_type']) {
                     if ($rowx['fee_type'] == 'appt') {
                         $subtext .= 'Court appointed.';
                     } else {
                         if ($rowx['balance']) {
                             $subtext .= 'Balance: $' . $rowx['balance'];
                         }
                     }
                 }
                 $item->addSubItem($subtext);
                 $list->addListItem($item);
             }
         } else {
             $list->addText('No cases.');
         }
         $list->echoList();
         $this->listAddresses($this->contact_id, 'client', $this->id);
         $this->listPhones($this->contact_id, 'client', $this->id);
     }
 }