Exemple #1
0
 public function setPaid($id, $paid)
 {
     try {
         $user = User::find(Session::uid());
         // Check if we have a payer
         if (!$user->isPayer()) {
             throw new Exception('Nothing to see here. Move along!');
         }
         // Get clean data
         $paid = $paid ? true : false;
         $notes = trim($_POST['notes']);
         if (!$notes) {
             throw new Exception('You must write a note!');
         }
         $fund_id = Fee::getFundId($id);
         // Exit of this script
         if (!Fee::markPaidById($id, $user->getId(), $notes, $paid, false, $fund_id)) {
             throw new Exception('Payment Failed!');
         }
         /* Only send the email when marking as paid. */
         if ($paid) {
             $fee = Fee::getFee($fee_id);
             $workitem = new WorkItem($fee['worklist_id']);
             $summary = $workitem->getSummary();
             $fee_user = User::find($fee['user_id']);
             $subject = "Worklist.net paid you " . $fee['amount'] . " for " . $summary;
             $body = "Your Fee was marked paid.<br/>" . "Job <a href='" . SERVER_URL . $fee['worklist_id'] . "'>#" . $fee['worklist_id'] . ': ' . $summary . '</a><br/>' . "Fee Description : " . nl2br($fee['desc']) . "<br/>" . "Paid Notes : " . nl2br($notes) . "<br/><br/>" . "Contact the job Designer with any questions<br/><br/>Worklist.net<br/>";
             if (!Utils::send_email($fee_user->getUsername(), $subject, $body)) {
                 error_log("FeeController::setPaid: Utils::send_email failed");
             }
         }
         return $this->setOutput(array('success' => true, 'notes' => 'Payment has been saved!'));
     } catch (Exception $e) {
         return $this->setOutput(array('success' => false, 'notes' => $e->getMessage()));
     }
 }
Exemple #2
0
 private function deleteFee($fee_id)
 {
     $workitem = new WorkItem($fee->worklist_id);
     $res = mysql_query('SELECT * FROM `' . FEES . '` WHERE `id`=' . $fee_id);
     $fee = mysql_fetch_object($res);
     // checking if is bidder or runner
     if (!empty($_SESSION['is_runner']) || $fee->user_id == $_SESSION['userid']) {
         mysql_unbuffered_query('UPDATE `' . FEES . '`
                                     SET `withdrawn` = 1
                                     WHERE `id` = ' . $fee_id);
         // Get worklist item summary
         $summary = $workitem->getSummary();
         // Get user
         $user = User::find($fee->user_id);
         if ($user->getId()) {
             // Journal message
             $message = '@' . $_SESSION['nickname'] . ' deleted a fee from @';
             $message .= $user->getNickname() . ' on #' . $fee->worklist_id;
             // Journal notification
             Utils::systemNotification($message);
             //sending email to the bidder
             $options = array();
             $options['emails'] = array($user->getUsername());
             $options['workitem'] = new WorkItem();
             $options['workitem']->loadById($fee->worklist_id);
             $options['type'] = "fee_deleted";
             Notification::workitemNotify($options);
             $data = array('nick' => $_SESSION['nickname'], 'fee_nick' => $user->getNickname());
             Notification::workitemNotifyHipchat($options, $data);
         }
     }
 }