Ejemplo n.º 1
0
    public static function ProjectReport()
    {
        $project = Project::GetProject($_GET['sid']);
        //, $_GET['period'], $_GET['all']
        echo '
				<div class="logo">
				  <h5 style="margin-bottom:-15px;margin-top:0px;font-size:14px;">Date: ' . date('d/m/Y') . '</h5>
				  <h4>' . $project->name . '</h4><h5>CLIENT: ' . $project->client->name . '</h5>';
        /*if ($_GET['period'] != '' && $_GET['period'] ) {
        			echo '<h5 style="margin-top:-10px">Period: '.$_GET['period'].'</h5>';
        		}	*/
        echo '</div>
				<h5>PROJECT ACTIVITIES</h5>
				<table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;">
			      <thead class="title">
			        <tr>
			          <td>NO</td>
			          <td>SERVICE</td>
			          <td>TASK</td>
			          <td>QTY</td>
			          <td>DATE PROPOSED</td>
			          <td>DATE EXECUTED</td>
					  <td>STATUS</td>
			        </tr>
			      </thead>
			      <tbody>';
        $count = 1;
        foreach ($project->activities as $activity) {
            if ($activity->status == 0) {
                $status = '<td style="color: #027c97">SCHEDULED</td>';
            } elseif ($activity->status == 1) {
                $status = '<td style="color: #e8e624">ON GOING</td>';
            } elseif ($activity->status == 2) {
                $status = '<td style="color: #e81c34">STALLED</td>';
            } elseif ($activity->status == 3) {
                $status = '<td style="color: #27c97b">COMPLETED</td>';
            } elseif ($activity->status == 4) {
                $status = '<td style="color: #9c2488">SUSPENDED</td>';
            }
            echo '<tr>
			      <td>' . $count . '</td>
			      <td>' . $activity->service . '</td>
			      <td>' . $activity->task . '</td>
			      <td>' . $activity->instances . '</td>
			      <td>' . $activity->requestDate . '</td>
			      <td>' . $activity->executionDate . '</td>' . $status . '
			      </tr>';
            $count++;
        }
        echo '</tbody>
			    </table>';
        echo '<h5>QUOTED ITEMS</h5>
					<table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;">
			      <thead class="title">
			        <tr>
			          <td>NO</td>
			          <td>SERVICE</td>
			          <td>DESCRIPTION</td>
			          <td>QTY</td>
			          <td>UNIT PRICE</td>
			          <td>VAT</td>
			          <td>SUB-TOTAL</td>					  
			        </tr>
			      </thead>
			      <tbody>';
        $count = 1;
        $amount = 0.0;
        foreach ($project->quotations as $quote) {
            foreach ($quote->lineItems as $item) {
                echo '<tr>
				      <td>' . $count . '</td>
				      <td>' . $item->itemName . '</td>
				      <td>' . $item->itemDesc . '</td>
				      <td>' . $item->quantity . '</td>
				      <td>' . $item->unitPrice . '</td>
				      <td>' . $item->tax . '</td>
				      <td><script>document.writeln((' . ($item->quantity * $item->unitPrice + $item->quantity * $item->unitPrice * $item->tax / 100) . ').formatMoney(2, \'.\', \',\'));</script></td>
				      </tr>';
                $count++;
            }
            $amount += $quote->total;
        }
        echo '</tbody>
			    </table>
			    <div class="logo">
			    <h5 style="margin: 5px 0 0 5px;float:right">Total Quoted: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5>				    
			   </div>';
        $invoices = SalesInvoice::GetProjectInvoices($_GET['sid'], $project->client);
        echo '<h5>INVOICED ITEMS</h5>
					<table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;">
			      <thead class="title">
			        <tr>
			          <td>NO</td>
			          <td>DATE</td>
			          <td>ITEM</td>
			          <td>DESCRIPTION</td>
			          <td>QTY</td>
			          <td>UNIT PRICE</td>
			          <td>VAT</td>
			          <td>SUB-TOTAL</td>					  
			        </tr>
			      </thead>
			      <tbody>';
        $count = 1;
        $amount = 0.0;
        foreach ($invoices as $invoice) {
            foreach ($invoice->lineItems as $item) {
                echo '<tr>
				      <td>' . $count . '</td>
				      <td>' . $invoice->date . '</td>
				      <td>' . $item->itemName . '</td>
				      <td>' . $item->itemDesc . '</td>
				      <td>' . $item->quantity . '</td>
				      <td>' . $item->unitPrice . '</td>
				      <td>' . $item->tax . '</td>
				      <td><script>document.writeln((' . ($item->quantity * $item->unitPrice + $item->quantity * $item->unitPrice * $item->tax / 100) . ').formatMoney(2, \'.\', \',\'));</script></td>
				      </tr>';
                $count++;
            }
            $amount += $invoice->total->amount;
        }
        echo '</tbody>
			    </table>
			    <div class="logo">
			    <h5 style="margin: 5px 0 0 5px;float:right">Total Invoiced: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5>				    
			   </div>';
        $expenses = ExpenseVoucher::GetProjectVouchers($_GET['sid'], $project->client);
        echo '<h5>PROJECT EXPENSES</h5>
					<table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;">
			      <thead class="title">
			        <tr>
			          <td>NO</td>
			          <td>DATE</td>
			          <td>PARTY</td>
			          <td>DESCRIPTION</td>
			          <td>AMOUNT</td>				  
			        </tr>
			      </thead>
			      <tbody>';
        $count = 1;
        $amount = 0.0;
        foreach ($expenses as $expense) {
            foreach ($expense->items as $item) {
                echo '<tr>
				      <td>' . $count . '</td>
				      <td>' . $expense->date . '</td>
				      <td>' . $item->claimant->name . '</td>
				      <td>' . $item->description . '</td>
				      <td><script>document.writeln((' . $item->adjusted . ').formatMoney(2, \'.\', \',\'));</script></td>
				      
				      </tr>';
                $count++;
                $amount += $item->adjusted;
            }
        }
        echo '</tbody>
			    </table>
			    <div class="logo">
			    <h5 style="margin: 5px 0 0 5px;float:right">Total Expensed: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5>				    
			   </div>';
        $payments = ReceiptVoucher::GetProjectReceipts($_GET['sid']);
        echo '<h5>RECEIVED PAYMENTS</h5>
					<table class="table table-bordered table-striped" style="text-align:center;margin-left:0;margin-right:0;width:760px;font-size:12px;">
			      <thead class="title">
			        <tr>
			          <td>REC. NO</td>
			          <td>DATE</td>
			          <td>AMOUNT</td>
			          <td>VOUCHER</td>
			          <td>DESCRIPTION</td>			  
			        </tr>
			      </thead>
			      <tbody>';
        $amount = 0.0;
        if (count($payments) > 0) {
            foreach ($payments as $payment) {
                echo '<tr>
					    <td>' . $payment['id'] . '</td>
					    <td>' . $payment['datetime'] . '</td>
					    <td><script>document.writeln((' . $payment['amount'] . ').formatMoney(2, \'.\', \',\'));</script></td>
					    <td>' . $payment['voucher_no'] . '</td>
					    <td>' . $payment['description'] . '</td>					    
					   </tr>';
                $amount += $payment['amount'];
            }
        }
        echo '</tbody>
			    </table>
			    <div class="logo">
			    <h5 style="margin: 5px 0 0 5px;float:right">Total Received: <b>Ksh. <script>document.writeln((' . $amount . ').formatMoney(2, \'.\', \',\'));</script></b></h5>				    
			   </div>';
    }
Ejemplo n.º 2
0
    public static function CreateSupplierProjectExpense($party, $scope, $amount, $account, $voucher, $description)
    {
        try {
            $datetime = new DateTime();
            $sql = 'INSERT INTO expense_vouchers (project_id, party_id, voucher_no, date, stamp, status) 
		VALUES (' . $scope . ', ' . $party . ', "' . $voucher . '", "' . $datetime->format('d/m/Y') . '", ' . $datetime->format('YmdHis') . ', 0)';
            DatabaseHandler::Execute($sql);
            $sql = 'SELECT * FROM expense_vouchers WHERE stamp = ' . $datetime->format('YmdHis');
            $res = DatabaseHandler::GetRow($sql);
            $voucher = new ExpenseVoucher($res['id'], $res['project_id'], $res['report_id'], $res['voucher_no'], 0, $res['date'], $res['stamp'], $res['status']);
            $voucher->addItem(ExpenseItem::Create($res['id'], $scope, $description, $account, $amount));
            return $voucher;
        } catch (Exception $e) {
            return false;
        }
    }
Ejemplo n.º 3
0
    public static function MakePayment($party, $scope, $supplierid, $amount, $ledgerId, $mode, $voucher, $descr)
    {
        try {
            $supplier = Supplier::GetSupplier($supplierid);
            $grns = "";
            /*foreach ($payments as $key => $payment) {
            			$grns .= $key.",";
            		}*/
            $descr .= ' (' . $voucher . ')';
            $sql = 'INSERT INTO payments (party_id, grns, amount, ledger_id, mode, voucher_no, description, status) VALUES 
			(' . $supplierid . ', "' . $grns . '", ' . $amount . ', ' . $ledgerId . ', "' . $mode . '", "' . $voucher . '", "' . $descr . '", 0)';
            DatabaseHandler::Execute($sql);
            $sql2 = 'SELECT * FROM payments WHERE party_id = ' . $supplierid . ' ORDER BY id DESC LIMIT 0,1';
            $res = DatabaseHandler::GetRow($sql2);
            $acc = Account::GetAccountByNo($supplierid, 'suppliers', 'Creditors');
            $expv = ExpenseVoucher::CreateSupplierProjectExpense($party, $scope, $amount, $acc->ledgerId, $voucher, $descr);
            if ($expv) {
                $tx = self::initialize($res);
                $tx->expVoucher = $expv;
                return $tx;
            } else {
                return false;
            }
            return self::initialize($res);
        } catch (Exception $e) {
        }
    }
Ejemplo n.º 4
0
 public function getProjectClaims($pid)
 {
     if ($this->validateAdmin()) {
         echo json_encode(ExpenseVoucher::GetProjectClaims($pid));
     } else {
         echo 0;
     }
 }
Ejemplo n.º 5
0
    public static function Create($projectId, $report, $charges)
    {
        try {
            $datetime = new DateTime();
            $sql = 'INSERT IGNORE INTO expense_vouchers (project_id, report_id, date, stamp, status) 
		VALUES (' . $projectId . ', ' . $report->id . ', "' . $datetime->format('d/m/Y') . '", ' . $datetime->format('YmdHis') . ', 0)';
            DatabaseHandler::Execute($sql);
            $sql = 'SELECT * FROM expense_vouchers WHERE stamp = ' . $datetime->format('YmdHis');
            $res = DatabaseHandler::GetRow($sql);
            $voucher = new ExpenseVoucher($res['id'], $res['project_id'], $res['report_id'], 0, $res['date'], $res['stamp'], $res['status']);
            foreach ($charges as $charge) {
                $voucher->addItem(ExpenseItem::Create($res['id'], $charge['claimant'], $charge['description'], $charge['category'], $charge['amount']));
            }
            return $voucher;
        } catch (Exception $e) {
        }
    }
Ejemplo n.º 6
0
 public function processClaim($ledgerId, $voucherId, $items, $details)
 {
     if ($this->validateAdmin()) {
         $adj = ExpenseItem::Adjust($items);
         if ($adj) {
             $vouch = ExpenseVoucher::GetVoucher(intval($voucherId));
             $tx = GeneralTransaction::PostClaim($ledgerId, $vouch->total, $vouch->items, $details);
             $claimslip = $tx->postprojectclaim($vouch);
             if ($claimslip) {
                 $vouch->authorize($tx->transactionId);
                 echo json_encode($claimslip);
             } else {
                 echo 0;
             }
         } else {
             echo 0;
         }
     } else {
         echo 0;
     }
 }
Ejemplo n.º 7
0
 public static function PostExpense($party, $crid, $drid, $amount, $voucher, $descr)
 {
     $entries = [];
     //Debit entry
     $entry['lid'] = $drid;
     $entry['effect'] = 'dr';
     $entry['amount'] = $amount;
     $entries[] = $entry;
     //Credit entry
     $entry['lid'] = $crid;
     $entry['effect'] = 'cr';
     $entry['amount'] = $amount;
     $entries[] = $entry;
     $evoucher = ExpenseVoucher::CreatePartyExpense($party, $amount, $drid, $voucher, $descr);
     if ($voucher) {
         $tx = new GeneralTransaction($entries, $voucher, $amount, $descr, "General Expenses");
         $tx->expVoucher = $evoucher;
         return $tx;
     } else {
         return false;
     }
 }
Ejemplo n.º 8
0
 public function testFileReport()
 {
     $client = Client::GetClient(2);
     $projects = Project::GetAll($client->id);
     $project = $projects[0];
     $pactivs = $project->getActivities();
     $pactiv = $pactivs[0];
     $tasks = $pactiv->id;
     $pactiv = $pactivs[1];
     $tasks += ', ' . $pactiv->id;
     $emp1 = Employee::GetClient(3);
     $personell = $emp1->id;
     $emp2 = Employee::GetClient(4);
     $personell += $emp2->id;
     $expvoucher = ExpenseVoucher::CreateEmpty();
     $expvoucher->addExpense('descr', 'expense account id', 'amount');
     $expvoucher->addExpense('descr', 'expense account id', 'amount');
     $project->fileReport($tasks, $personell, 'action report', $expvoucher->id);
 }