Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBFS and autoItem update #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 26 additions & 3 deletions system/modules/li_crm/assets/crm.css
Expand Up @@ -182,6 +182,10 @@ label.print {
padding-bottom: 5px;
}

#working_hours_calendar thead .date {
font-weight:normal;
}

#working_hours_calendar, #working_hours_calendar td {
border: 1px solid #bbb;
}
Expand All @@ -197,19 +201,38 @@ label.print {

#working_hours_calendar td .working_hour_entry {
border: 1px solid #bbb;
padding: 5px;
padding: 4px 5px 5px 5px;
margin-bottom: 5px;
position: relative;
}

#working_hours_calendar td .working_hour_entry .entry_buttons {
text-align: right;
margin-top: 15px;
margin-top: 10px;
line-height: 0;
}

#working_hours_calendar td .working_hour_entry .entry_buttons a {
margin-left: 5px;
margin-left: 4px;
}

#working_hours_calendar td .working_hour_entry span.user,
#working_hours_calendar td .working_hour_entry span.description {
display: block;
}

#working_hours_calendar td .working_hour_entry span.description {
color: rgb(0,0,0);
}
/*
#working_hours_calendar td .working_hour_entry div.color {
width: 100%;
height: 5px;
position: absolute;
left: 0px;
top: 0px;
}
*/
.li_positions .header {
height: 17px;
}
Expand Down
23 changes: 21 additions & 2 deletions system/modules/li_crm/classes/Invoice.php
Expand Up @@ -99,7 +99,7 @@ public function generateAlias($varValue, \DataContainer $dc)
}

// Add ID to alias
if ($objAlias->numRows && $autoAlias)
if ($objAlias->numRows && $autoAlias && strlen($varValue) > 0)
{
$varValue .= '-'.$dc->id;
}
Expand Down Expand Up @@ -1063,7 +1063,16 @@ private function returnFile($id)
WHERE id = ?
")->limit(1)->execute($id);

$path = '../'.$objInvoice->pdfFile;
// in Contao 3, we need to get the path via DBFS
if (is_numeric($objInvoice->pdfFile))
{
$objFile = \FilesModel::findByPk($objInvoice->pdfFile);
$path = '../'.$objFile->path;
}
else
{
$path = '../'.$objInvoice->pdfFile;
}

$filename = basename($path);
header('Content-type: application/pdf');
Expand All @@ -1084,6 +1093,11 @@ public function returnFileForFrontend($id)
if ($objInvoice->toCustomer == $this->User->id)
{
$path = $objInvoice->pdfFile;
if (is_numeric($path))
{
$objFile = \FilesModel::findByPk($path);
$path = $objFile->path;
}
$filename = basename($path);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.$filename.'"');
Expand All @@ -1097,6 +1111,11 @@ public function returnFileForFrontend($id)
else
{
$path = $objInvoice->pdfFile;
if (is_numeric($path))
{
$objFile = \FilesModel::findByPk($path);
$path = $objFile->path;
}
$filename = basename($path);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.$filename.'"');
Expand Down
10 changes: 9 additions & 1 deletion system/modules/li_crm/classes/InvoiceTemplate.php
Expand Up @@ -27,7 +27,15 @@ public function getInvoiceTemplates(\DataContainer $dc)
return $this->getTemplateGroup('invoice_');
}

public function moveHtaccessFile($path, \DataContainer $dc) {
public function moveHtaccessFile($path, \DataContainer $dc)
{
// in Contao 3 we need to get the path via the DBFS
if (is_numeric($path))
{
$objFile = \FilesModel::findByPk($path);
$path = $objFile->path;
}

$exportPath = '../'.$path.'/';
$htaccess = '.htaccess';

Expand Down
51 changes: 42 additions & 9 deletions system/modules/li_crm/classes/WorkingHourCalendar.php
Expand Up @@ -21,44 +21,76 @@ class WorkingHourCalendar extends \BackendModule
public function generate()
{
parent::generate();

// Get the desired year or set default values
if (isset($_REQUEST['tl_li_year']))
{
$year = $_REQUEST['tl_li_year'];
}
elseif (isset($_SESSION['tl_li_year']))
{
$year = $_SESSION['tl_li_year'];
}
else
{
$year = date('Y');
}

// Get the desired week range or set default values
if (!empty($_REQUEST['tl_li_week']))
if (isset($_REQUEST['tl_li_week']))
{
$week = $_REQUEST['tl_li_week'];
}
elseif (!empty($_SESSION['tl_li_week']))
elseif (isset($_SESSION['tl_li_week']))
{
$week = $_SESSION['tl_li_week'];
}
else
{
$week = date('W');
}

// Save the displayed week in the session so it will be restored if the user leaves the page

// catch 0 week and greater than 53 week
if( $week <= 0 )
{
$year--;
$week = $week + 53;
}
if( $week > 53 )
{
$year++;
$week = $week - 53;
}

// clamp the week
$week = min( 53, max( 1, $week ) );

// Save the displayed week and year in the session so it will be restored if the user leaves the page
$_SESSION['tl_li_week'] = $week;
$_SESSION['tl_li_year'] = $year;

// Save template variables for previous, current and next week numbers
$this->Template->week = $week;
$this->Template->prevWeek = ($week - 1 <= 0) ? 53 : $week - 1;
$this->Template->nextWeek = ($week + 1 > 53) ? 1 : $week + 1;
$this->Template->prevWeek = $week - 1;
$this->Template->nextWeek = $week + 1;
$this->Template->year = $year;

// Get the configured week mode from the configuration
$weekMode = !empty($GLOBALS['TL_CONFIG']['li_crm_timekeeping_week_mode']) ? $GLOBALS['TL_CONFIG']['li_crm_timekeeping_week_mode'] : '7';
$weekMode = 3;//!empty($GLOBALS['TL_CONFIG']['li_crm_timekeeping_week_mode']) ? $GLOBALS['TL_CONFIG']['li_crm_timekeeping_week_mode'] : '3';

// Only get the working hours in the desired week range
$getWorkingHours = $this->Database->prepare("SELECT wh.id, WEEKDAY(FROM_UNIXTIME(wh.entryDate)) AS weekday,
(wh.hours * 60 + wh.minutes) AS minutes, wp.id AS workPackageId, c.customerColor,
u.username AS username, u.name as `user`
u.username AS username, u.name as `user`, wh.description as description
FROM tl_li_working_hour wh
INNER JOIN tl_li_work_package wp ON wh.toWorkPackage = wp.id
LEFT JOIN tl_li_project p ON wp.toProject = p.id
LEFT JOIN tl_member c ON p.toCustomer = c.id
LEFT JOIN tl_user u ON wh.user = u.id
WHERE hours IS NOT NULL
AND WEEK(FROM_UNIXTIME(wh.entryDate), ?) = ?
ORDER BY wh.entryDate")->execute($weekMode, $week);
AND YEAR(FROM_UNIXTIME(wh.entryDate)) = ?
ORDER BY wh.entryDate")->execute($weekMode, $week, $year);

// Build an array of the working hours per day. The first index is the week of the year,
// the second is the day within that week
Expand All @@ -78,6 +110,7 @@ public function generate()
'customerId' => $getWorkingHours->customerId,
'workPackageId' => $getWorkingHours->workPackageId,
'user' => $getWorkingHours->user ? $getWorkingHours->user : $getWorkingHours->username,
'description' => $getWorkingHours->description,
'foo' => $getWorkingHours->row()
);

Expand Down
11 changes: 10 additions & 1 deletion system/modules/li_crm/dca/tl_li_working_hour.php
Expand Up @@ -38,7 +38,7 @@
'palettes' => array
(
'__selector__' => array('isExternal'),
'default' => '{hour_legend},entryDate,toWorkPackage,hours,minutes;'
'default' => '{hour_legend},entryDate,toWorkPackage,hours,minutes,description;'
),

// Fields
Expand Down Expand Up @@ -92,6 +92,15 @@
'exclude' => true,
'eval' => array('rgxp'=>'digit', 'maxlength'=>'2', 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'description' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_li_working_hour']['description'],
'exclude' => true,
'inputType' => 'textarea',
'search' => true,
'eval' => array('style'=>'height:60px', 'decodeEntities'=>true, 'tl_class'=>'clr'),
'sql' => "text NULL"
)
)
);
3 changes: 3 additions & 0 deletions system/modules/li_crm/languages/de/tl_li_working_hour.php
Expand Up @@ -18,8 +18,11 @@
$GLOBALS['TL_LANG']['tl_li_working_hour']['manageWorkPackages'] = "Arbeitspakete verwalten";
$GLOBALS['TL_LANG']['tl_li_working_hour']['editWorkPackage'] = "Zugehöriges Arbeitspaket bearbeiten";

$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_year'] = "Kalenderjahr";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_week'] = "Kalenderwoche";

$GLOBALS['TL_LANG']['tl_li_working_hour']['editEntry'] = "Stundeneintrag bearbeiten";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteEntry'] = "Stundeneintrag löschen";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteConfirmDialog'] = "Diesen Stundeneintrag wirklich löschen?";

$GLOBALS['TL_LANG']['tl_li_working_hour']['description'] = array("Beschreibung","Beschreibung der Tätigkeiten");
3 changes: 3 additions & 0 deletions system/modules/li_crm/languages/en/tl_li_working_hour.php
Expand Up @@ -18,8 +18,11 @@
$GLOBALS['TL_LANG']['tl_li_working_hour']['manageWorkPackages'] = "Manage work packages";
$GLOBALS['TL_LANG']['tl_li_working_hour']['editWorkPackage'] = "Edit the work package";

$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_year'] = "Calendar year";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_week'] = "Calendar week";

$GLOBALS['TL_LANG']['tl_li_working_hour']['editEntry'] = "Edit the entry";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteEntry'] = "Delete the entry";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteConfirmDialog'] = "Are you sure you want to delete this entry?";

$GLOBALS['TL_LANG']['tl_li_working_hour']['description'] = array("Description","Description of the work that was done");
2 changes: 2 additions & 0 deletions system/modules/li_crm/languages/fr/tl_li_working_hour.php
Expand Up @@ -27,9 +27,11 @@
$GLOBALS['TL_LANG']['tl_li_working_hour']['addHours'] = "Ajouter l'enregistrement";
$GLOBALS['TL_LANG']['tl_li_working_hour']['manageWorkPackages'] = "Gérer les lots de travail";
$GLOBALS['TL_LANG']['tl_li_working_hour']['editWorkPackage'] = "Modifier le lot de travail";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_year'] = "Calendar year";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_week'] = "Semaine calendaire";
$GLOBALS['TL_LANG']['tl_li_working_hour']['editEntry'] = "Modifier l'enregistement";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteEntry'] = "Supprimer l'enregistrement";
$GLOBALS['TL_LANG']['tl_li_working_hour']['deleteConfirmDialog'] = "Etes-vous sûr(e) de vouloir supprimer cet enregistrement ?";
$GLOBALS['TL_LANG']['tl_li_working_hour']['description'] = array("Description","Description des travaux qui était don");

?>
2 changes: 2 additions & 0 deletions system/modules/li_crm/languages/nl/tl_li_working_hour.php
Expand Up @@ -30,6 +30,8 @@
$GLOBALS['TL_LANG']['tl_li_working_hour']['addHours'] = "Boeking toevoegen";
$GLOBALS['TL_LANG']['tl_li_working_hour']['manageWorkPackages'] = "Werkpakketten beheren";
$GLOBALS['TL_LANG']['tl_li_working_hour']['editWorkPackage'] = "Werkpakket bewerken";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_year'] = "Calendar year";
$GLOBALS['TL_LANG']['tl_li_working_hour']['calendar_week'] = "Kalenderweek";
$GLOBALS['TL_LANG']['tl_li_working_hour']['description'] = array("Description","Description of the work that was done");

?>
5 changes: 3 additions & 2 deletions system/modules/li_crm/modules/ModuleInvoiceList.php
Expand Up @@ -79,6 +79,7 @@ protected function compile()

$arrInvoices = array();
$currencyHelper = new CurrencyHelper();
$itemurl = ( $GLOBALS['TL_CONFIG']['useAutoItem'] ) ? '/' : '/items/';
while($objInvoices->next() != null)
{
$newArray = array
Expand All @@ -89,9 +90,9 @@ protected function compile()
'price' => $this->getFormattedNumber($objInvoices->price).' '.$currencyHelper->getSymbolOfCode($objInvoices->currency),
'currency' => strtolower($objInvoices->currency),
'fileAvailable' => $objInvoices->file != '',
'file' => $this->generateFrontendUrl($objPage->row(), '/items/'. $objInvoices->alias).'?key=pdf&id='.$objInvoices->id,
'file' => $this->generateFrontendUrl($objPage->row(), $itemurl . $objInvoices->alias).'?key=pdf&id='.$objInvoices->id,
'cssClass' => $objInvoices->cssClass,
'details' => $this->generateFrontendUrl($objPage->row(), '/items/'. $objInvoices->alias)
'details' => $this->generateFrontendUrl($objPage->row(), $itemurl . $objInvoices->alias)
);
$arrInvoices[] = $newArray;
}
Expand Down
3 changes: 2 additions & 1 deletion system/modules/li_crm/modules/ModuleInvoiceReader.php
Expand Up @@ -83,14 +83,15 @@ protected function compile()
if ($objInvoice->numRows == 1)
{
$currencyHelper = new CurrencyHelper();
$itemurl = ( $GLOBALS['TL_CONFIG']['useAutoItem'] ) ? '/' : '/items/';
$arrInvoice = array(
'id' => $objInvoice->id,
'title' => $objInvoice->title,
'date' => $objInvoice->invoiceDate,
'price' => $this->getFormattedNumber($objInvoice->price).' '.$currencyHelper->getSymbolOfCode($objInvoice->currency),
'currency' => strtolower($objInvoice->currency),
'fileAvailable' => $objInvoice->file != '',
'file' => $this->generateFrontendUrl($objPage->row(), '/items/'. $objInvoice->alias).'?key=pdf&id='.$objInvoice->id,
'file' => $this->generateFrontendUrl($objPage->row(), $itemurl . $objInvoice->alias).'?key=pdf&id='.$objInvoice->id,
'cssClass' => $objInvoice->cssClass
);
$this->Template->invoice = $arrInvoice;
Expand Down
3 changes: 2 additions & 1 deletion system/modules/li_crm/modules/ModuleMobileCustomerList.php
Expand Up @@ -68,6 +68,7 @@ protected function compile()
")->limit(1)->execute($this->jumpTo);

$arrCustomers = array();
$itemurl = ( $GLOBALS['TL_CONFIG']['useAutoItem'] ) ? '/' : '/items/';
while($objCustomers->next() != null)
{
$objAddresses = $this->Database->prepare("
Expand All @@ -83,7 +84,7 @@ protected function compile()
'id' => $objAddresses->id,
'firstname' => $objAddresses->firstname,
'lastname' => $objAddresses->lastname,
'link' => $this->generateFrontendUrl($objPage->row(), '/items/'. $objAddresses->id)
'link' => $this->generateFrontendUrl($objPage->row(), $itemurl . $objAddresses->id)
);
}
$arrCustomers[] = array
Expand Down
3 changes: 2 additions & 1 deletion system/modules/li_crm/modules/ModuleTaskList.php
Expand Up @@ -79,6 +79,7 @@ protected function compile()
")->limit(1)->execute($this->jumpTo);

$arrTasks = array();
$itemurl = ( $GLOBALS['TL_CONFIG']['useAutoItem'] ) ? '/' : '/items/';
while($objTasks->next() != null)
{
$newArray = array
Expand All @@ -90,7 +91,7 @@ protected function compile()
'status' => $objTasks->status,
'icon' => $objTasks->icon,
'cssClass' => $objTasks->cssClass,
'details' => $this->generateFrontendUrl($objPage->row(), '/items/'. $objTasks->alias)
'details' => $this->generateFrontendUrl($objPage->row(), $itemurl . $objTasks->alias)
);
$arrTasks[] = $newArray;
}
Expand Down
2 changes: 2 additions & 0 deletions system/modules/li_crm/templates/be_settings.html5
Expand Up @@ -60,6 +60,7 @@
</div>

<h2><?php echo $GLOBALS['TL_LANG']['li_settings']['timekeeping']; ?></h2>
<!--
<div class="tl_module_desc">
<h3>
<a href="contao/main.php?do=li_settings&amp;table=tl_li_timekeeping_settings&rt=<?php echo REQUEST_TOKEN;?><?php echo (!defined('TL_REFERER_ID')) ?: '&ref='.TL_REFERER_ID;?>" class="navigation" style="background-image:url('system/modules/li_crm/assets/timekeeping.png')">
Expand All @@ -68,6 +69,7 @@
</h3>
<p><?php echo $GLOBALS['TL_LANG']['li_settings']['workingHoursDesc']; ?></p>
</div>
-->
<div class="tl_module_desc">
<h3>
<a href="contao/main.php?do=li_settings&amp;table=tl_li_hourly_wage&rt=<?php echo REQUEST_TOKEN;?><?php echo (!defined('TL_REFERER_ID')) ?: '&ref='.TL_REFERER_ID;?>" class="navigation"
Expand Down