debug_message($ta->getLastError()); } }else{ fatal_error("Task ID must be supplied!\n"); } $my_url = $_SERVER['PHP_SELF']."?task_id=".$task->id."&"; $_REQUEST['detail'] = strtolower(substr($_REQUEST['detail'],0,1)) == "y" ? TRUE : FALSE; $title = "Time for ".$task->name; $total_time = 0; // Get this tasks payment schedule $ps = new SI_PaymentSchedule(); $items = $ps->getForTask($task->id); if($items === FALSE){ $error_msg .= "Error getting scheduled billings for project!\n"; debug_message($ps->getLastError()); } require('header.php') ?> <form action="batch_process.php" method="GET"> <input type="hidden" name="type" value="activity"/> <div class="tableContainer"> <a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"> <img src="images/arrow_down.jpg" alt="Hide table" />Task Information</a><div> <table border="0" cellspacing="0" cellpadding="0" class="form_table"> <tr>
* with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); require_once('includes/SI_PaymentSchedule.php'); require_once('includes/SI_CompanyTransaction.php'); require_once('includes/SI_Project.php'); require_once('includes/SI_Task.php'); require_once('includes/SI_ItemCode.php'); checkLogin('accounting'); $title = ''; $ps = new SI_PaymentSchedule(); $project = new SI_Project(); $task = new SI_Task(); $item_code = new SI_ItemCode(); // Clean up amount if(!empty($_POST['amount'])){ $_POST['amount'] = preg_replace('/[^0-9\.]/','', $_POST['amount']); } if($_REQUEST['mode'] == 'add'){ $title = "Add Scheduled Billing"; $project_id = intval($_REQUEST['project_id']); $task_id = intval($_REQUEST['task_id']); if($project_id == 0 && $task_id == 0){
$activity = new SI_TaskActivity(); $temp_array = $activity->getActivitiesForCompany($compid); if ($temp_array != NULL) { $ta_ids = ''; foreach ($temp_array as $temptask) { $ta_ids[] = $temptask->id; } $ta_ids = array_unique($ta_ids); } if (count($ta_ids) > 0) { if ($invoice->addTaskActivities($ta_ids, SI_ACTIVITY_AGGREGATION_TASK) === FALSE) { $error_msg .= "Error adding activities to invoice!\n"; debug_message($invoice->getLastError()); } } $ps = new SI_PaymentSchedule(); $ps_array = $ps->getForCompany($compid); if ($ps_array != NULL) { $ps_ids = ''; foreach ($ps_array as $tempps) { $ps_ids[] = $tempps->id; } $ps_ids = array_unique($ps_ids); } if (count($ps_ids) > 0) { if ($invoice->addPaymentSchedules($ps_ids) === FALSE) { $error_msg .= "Error adding payment schedules to invoice!\n"; debug_message($invoice->getLastError()); } } $expense_array = $company->getExpenses(TRUE);
function generateScheduledPayments($project_id, $task_id, $frequency, $start_ts, $end_ts, $item_code, $description_format, $amount){ $months = array( 1 => 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'); $scheduled_payments = array(); if($frequency == 'Monthly'){ $dom = (int)date('d', $start_ts); $start_month = (int)date('m', $start_ts); $start_year = (int)date('Y', $start_ts); $end_month = (int)date('m', $end_ts); $end_year = (int)date('Y', $end_ts); $current_month = $start_month; $current_year = $start_year; //print("From $start_month/$start_year to $end_month/$end_year on the $dom\n"); while($current_year < $end_year || $current_month <= $end_month && $current_year == $end_year){ //print("Creating payment for $current_month/$dom/$current_year\n"); $ps = new SI_PaymentSchedule(); if($task_id > 0){ $ps->task_id = $task_id; $task = $ps->getTask(); $ps->project_id = $task->project_id; }else{ $ps->project_id = $project_id; } $ps->amount = $amount; $ps->due_ts = strtotime($current_year.'-'.$current_month.'-'.$dom); if(stristr($description_format, '|MONTH|')){ $ps->description = str_replace('|MONTH|', $months[(int)$current_month], $description_format); }else{ $ps->description = $description_format; } $ps->item_code_id = $item_code; if($ps->add()){ $scheduled_payments[] = $ps; }else{ return FALSE; } if($current_month == 12){ $current_month = 1; $current_year++; }else{ $current_month++; } //print("Next date $current_month/$dom/$current_year\n"); } } return $scheduled_payments; }
<tr> <td valign="top" nowrap><b><?php echo date("n/j/y H:i", $ta->start_ts) . "-" . date("H:i", $ta->end_ts); ?> </b></td> <td valign="top"><?php echo $ta->text; ?> </td> </tr> </table> </td> </tr> <? } if($links[$x]->payment_schedule_id > 0){ $ps = new SI_PaymentSchedule(); $ps->get($links[$x]->payment_schedule_id); ?> <tr> <td colspan="11" class="dg_data_cell_1"><?php echo $ps->description; ?> </td> </tr> <? } ?> <? } // end for links if($i != count($activities)-1){?> <tr> <td colspan="11" class="dg_header_cell"> </td> </tr> <? } //If not last ?> <? } //If detail ?>
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); require_once('includes/SI_PaymentSchedule.php'); checkLogin('accounting'); $ps = new SI_PaymentSchedule(); $ps_items = $ps->getUpcoming(); if($ps_items === FALSE){ $error_msg .= "Could not retreive upcoming scheduled billings!\n"; debug_message($ps->getLastError()); } $title = "Scheduled Billings"; require('header.php'); ?> <div class="tableContainer"> <a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"> <img src="images/arrow_down.jpg" alt="Hide table" />All Scheduled Billings</a><div> <table border="0" cellspacing="0" cellpadding="0" class="dg_table"> <? if(count($ps_items) > 0){?> <tr> <th class="dg_header_cell"><a class="link1" href="" onclick="return sortTable('bodyId5', 0, 1, false)">Company</a></th>
function addPaymentSchedules($ps_ids){ if(!is_array($ps_ids) || count($ps_ids) <= 0){ $this->error = "SI_Invoice::addPaymentSchedules(): Invalid parameter!"; return FALSE; } $clause = " WHERE id IN (".implode(',', $ps_ids).")"; $ps = new SI_PaymentSchedule(); $ps_items = $ps->retrieveSet($clause); if($ps_items === FALSE){ $this->error = "SI_Invoice::addPaymentSchedules(): Error getting payment schedules: ".$ps->getLastError(); return FALSE; } $ps_count = count($ps_items); $lines = array(); for($i=0; $i<$ps_count; $i++){ if($ps_items[$i]->getProject() === FALSE){ $this->error = "SI_Invoice::addPaymentSchedules(): Error getting project for payment schedule: ".$tas[$i]->getLastError(); return FALSE; } $il = new SI_InvoiceLine(); $il->invoice_id = $this->id; $il->quantity = 1; $il->item_code_id = $ps_items[$i]->item_code_id; $il->unit_price = $ps_items[$i]->amount; $il->description = $ps_items[$i]->_project->name.": ".$ps_items[$i]->description; $ill = new SI_InvoiceLineLink(); $ill->payment_schedule_id = $ps_items[$i]->id; $il->_links[] = $ill; $il->addTax(); $lines[] = $il; } if(!$this->_lines) $this->_lines = array(); foreach($lines as $line){ if($line->add() === FALSE){ $this->error = "SI_Invoice::addPaymentSchedules(): Error adding line item: ".$line->getLastError(); return FALSE; } $this->_lines[] = $line; } return TRUE; }
function getUnitPrice(){ if($this->task_activity_id > 0){ $ta = new SI_TaskActivity(); if($ta->get($this->task_activity_id) === FALSE){ $this->error = 'SI_InvoiceLineLink::getUnitPrice(): Error getting task activity: '.$ta->getLastError(); return FALSE; } return $ta->hourly_rate; }elseif($this->expense_id > 0){ $ex = new SI_Expense(); if($ex->get($this->expense_id) === FALSE){ $this->error = 'SI_InvoiceLineLink::getPrice(): Error getting expense: '.$ex->getLastError(); return FALSE; } return $ex->price; }elseif($this->payment_schedule_id > 0){ $ps = new SI_PaymentSchedule(); if($ps->get($this->payment_schedule_id) === FALSE){ $this->error = 'SI_InvoiceLineLink::getPrice(): Error getting scheduled payment: '.$ps->getLastError(); return FALSE; } return $ps->amount; } return 'Unknown'; }
$ct->amount += $line->getTotal(); if($ct->update() === FALSE){ $error_msg .= "Error updating company transaction with new price"; debug_message($ct->getLastError()); }else{ header('Location: '.getCurrentURL('invoice_edit.php').'?id='.$invoice->id."\r\n"); die(); } } } } } $activity = new SI_TaskActivity(); $ps = new SI_PaymentSchedule(); $activities = $activity->getActivitiesForCompany($invoice->company_id, true, 0, true); if($activities === FALSE){ $error_msg .= "Could not retrieve Activity List for Company!\n"; debug_message($activity->getLastError()); } $items = $ps->getForCompany($invoice->company_id); if($items === FALSE){ $error_msg .= "Could not retrieve scheduled payments for Company!\n"; debug_message($ps->getLastError()); } $expenses = $company->getExpenses(TRUE); if($expenses === FALSE){ $error_msg .= "Could not retrieve expenses for Company!\n";
$task = new SI_Task(); if($_REQUEST['filter'] == "all"){ $tasks = $task->retrieveSet("t.deleted = 'N' AND t.project_id = ".$project->id); }else{ $tasks = $task->retrieveSet("t.deleted = 'N' AND t.project_id = ".$project->id." AND s.completed = 'N'"); } if($tasks === FALSE){ $error_msg .= "Error retrieving tasks for project!\n"; debug_message($task->getLastError()); } }else{ fatal_error("Project ID must be supplied!\n"); } // Get this projects payment schedule $ps = new SI_PaymentSchedule(); $items = $ps->getForProject($project->id); if($items === FALSE){ $error_msg .= "Error getting scheduled payments for project!\n"; debug_message($ps->getLastError()); } $title = "Tasks for ".$project->name; require('header.php') ?> <div class="tableContainer"> <a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" />Project Information</a><div> <table border="0" cellspacing="0" cellpadding="0" class="form_table"> <tr> <td class="form_field_header_cell">Name:</td> <td class="form_field_cell">
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); require_once('includes/SI_Invoice.php'); require_once('includes/SI_Company.php'); require_once('includes/SI_TaskActivity.php'); require_once('includes/SI_PaymentSchedule.php'); require_once('includes/SI_ItemCode.php'); checkLogin('accounting'); $num_custom_lines = 5; $activity = new SI_TaskActivity(); $ps = new SI_PaymentSchedule(); $invoice = new SI_Invoice(); $item_code = new SI_ItemCode(); if ($_POST['save']){ $ta_ids = $_POST['task_activity_ids']; $ps_ids = $_POST['payment_schedule_ids']; $ex_ids = $_POST['expense_ids']; $at_least_one = false; if(count($ta_ids) == 0 && count($ps_ids) == 0 && count($ex_ids) == 0){ if(isset($_REQUEST['custom']) && is_array($_REQUEST['custom'])){ foreach($_REQUEST['custom'] as $custom_line){ if($custom_line['quantity'] > 0 || $custom_line['description'] != ''){ $at_least_one = true; }