fwd('/start/'); } $usr->checkLoggedIn(); $L->requireClient = False; $L->useNoClientList = True; $L->incHead .= ''; $L->topLine .= '
New! ' . $L->lnk( 'Zapier Integration', 'https://zapier.com/developer/public-invite/26435/460e39350c88dec77c3e6220731c4d0e/', ['class' => 'btn btn-secondary', 'icon' => 'asterisk'] ) . '
'; $lgi = 'list-group-item list-group-item-action'; ///// // Plans List /// $planCard = null; if ($usr->getCurPlan()) { $planCard = $L->lnk('Exit Current Guest Plan', '/myplan/switch.php', $lgi); } else { $plans = $usr->getPlans(); if (count($plans) > 1) { foreach ($plans as $plan) { $planCard .= $L->lnk($plan['summary'], '/myplan/switch.php?p=' . $plan['id'], $lgi); } } } if ($planCard) { $planCard = '

' . $L->lnk('Plans', '/myplan/pick.php', 'text-white card-title') . '

' . $planCard . '
'; } ///// // Clients List /// $clientCard = null; $myClients = User\Permission::getActiveClients(); if (count($myClients) > 1) { $curCli = $usr->getCurClient(); foreach ($myClients as $client) { $active = ($curCli == $client['id']) ? ' bg-secondary' : null; $clientCard .= Client::URL($client['name'], $client['id'], $lgi . $active); } } elseif (isset($myClients[0])) { $curCli = $usr->getCurClient(); if (!$curCli) { $usr->setCurClient($myClients[0]['id'], $myClients[0]['name'], 1); } } if ($clientCard) { $clientCard = '

' . $L->lnk('Clients', '/clients/', 'text-white card-title') . '

' . $clientCard . '
'; } $myClients = $iQ::makeRange($myClients); ///// // Find Porting and Unused Numbers /// $porting = $detached = null; $numDet = $numPor = 0; $plan = $usr->getInf('plan'); $probWhere = ($plan) ? 'plan=' . $plan : 'plan IS NULL AND userGroup=' . $grp->id; $ProbNums = $iQ->getSquare(' SELECT bw_numberID, DID, porting FROM bw_numbers WHERE ' . $probWhere . ' AND enabled=1 AND (campaign IS NULL OR porting=1) ', 'DID'); foreach ($ProbNums as $prob) { $link = $L->aL([formatPhone($prob['DID']), $prob['DID']], 'numbers', $prob['bw_numberID']); if ($prob['porting']) { $numPor++; $porting .= '
  • ' . $link . '
  • '; } elseif ($plan) { $numDet++; $detached .= '
  • ' . $link . '
  • '; } } ///// // Calls to Clients Today /// $day = 60*60*24; $start = time() - $day * 8; $startStamp = date('Y-m-d', $start) . ' 00:00:00'; $today = date('Y-m-d'); $dayTotal = 0; $weekTotal = 0; $G = new Chart\GoogleChart(); $DayData = new DataSet\DataSet(); $DayData->setSorting('keys'); $weekDataSet = new DataSet\Time(); $weekDataSet->setTimeRange($startStamp, strtotime($today) - $day); $weekDataSet->setTyping('date', 'Date'); $myClients = User\Permission::getActiveClients(); $myClients = $iQ::makeRange($myClients); $read = $iQ->read(" SELECT DATE(c.startTime) stamp, count(c.bw_callID) total, c.client, x.name FROM bw_calls c JOIN clients x ON ( x.clientID = c.client ) WHERE c.client IN $myClients AND c.startTime > '$startStamp' GROUP BY x.clientID, DATE(c.startTime) "); while ($row = $read->fetch_assoc()) { $name = cutName($row['name']); $name = preg_replace("/[^a-zA-Z0-9 ]+/", "", $name); if ($row['stamp'] == $today) { $DayData->add($name, $row['total']); $DayData->keyIDs[$name] = linkify('clients', $row['client'], $name); $dayTotal += $row['total']; } else { $weekDataSet->add($row['stamp'], $row['total'], $name); $weekTotal += $row['total']; } } $read->free(); $dayTotalSay = ($dayTotal == 1) ? ' Call Today' : ' Calls Today'; $weekTotalSay = ($weekTotal == 1) ? ' Call This Week' : ' Calls This Week'; $gBar = new Chart\Stack($weekTotalSay); $gBar->links[] = 1; $gBar->addStackButton(); $gBar->setOptionPresets([ 'chartArea' => ['bottom' => 20, 'right' => 0, 'top' => 40], 'hAxis' => [ 'format' => 'E', 'minorGridlines' => ['count' => 0], 'slantedText' => False, 'viewWindowMode' => 'maximized', ], 'isStacked' => True, 'legend' => [ 'maxLines' => 2, 'position' => 'top', ], ]); if ($weekTotal) { $gBar->addTable($weekDataSet->getDataTable()); $G->addChart($gBar); } $gPie = new Chart\Pie('Day Pie'); $gPie->centerText = '
    ' . number_format($dayTotal) . '
    ' . $dayTotalSay . '
    '; $gPie->addColumnArray([ ['string', 'Client'], ['number', 'Count'] ]); $gPie->links = $DayData->keyIDs; $gPie->addRowArray($DayData->getRowArray()); $G->addChart($gPie); ///// // State Map /// $states = $iQ->getSquare(" SELECT substring(city,-2) state, count(bw_callID) calls FROM vCalls WHERE client IN $myClients AND startTime > '$startStamp' GROUP BY state "); if ($states) { $Map = new Chart\Geo('Calls By State'); $Map->setOptionPresets(); $Map->options['displayMode'] = 'regions'; $Map->interactive = false; $Map->addColumnArray([ ['string', 'Cities'], ['number', 'Calls'] ]); $Map->addRowArray($states); $G->addChart($Map); } $L->addGoogleChart($G); $L->header('Hello'); Print $planCard . $clientCard; # Total Calls Today if ($dayTotal) { ?>

    Calls Today

    getContainer('height:400px;') ?>

    Calls By State

    getStackButton('float-end btn btn-xs btn-primary') ?>

    getContainer('height:400px;') ?>

    Porting

    > Parked Numbers