Jump to content
Latest News: (loading..)
kymation

[Contribution] Documents Manager

Recommended Posts

That sounds right to me. I'm out of suggestions. You'll just have to debug it.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

That sounds right to me. I'm out of suggestions. You'll just have to debug it.

 

Regards

Jim

 

Thanks Jim.

 

I know the catalog document manager working, but the video and other don't work. So I will compare the two and try to find out the differences. Maybe come back for help later. ^-^ if I can not figure out......

 

Thanks

 

Lyn

Share this post


Link to post
Share on other sites

Dear Jim,

 

first and foremost: Thank you for this useful contribution. It exactly meets my requirements. I have updated the contribution for osC 2.3.3, no trouble so far.

 

Since I want to support different languages, I am just adding this to your Documents Manager. It works quite well already, but there are questions left:

 

(concerning catalog/admin/documents.php)

a. During association of products to documents there is now need for an input field for language_id

row 631: (case 'associate': )

I cant see exactly how you handle the association. Please help with adding an input field where users can input desired language_id (Can also be a drop down selector with languages found, more elegant but not necessary).

 

b. The update of db has to be modified to save the language_id given above

row 295 (case 'doc_associate_confirm': )

I guess this follows from answer to a.

 

It would be very nice to get some support with this. After completion it will be a pleasure for me to provide the updated package.

 

Kind Regards

heranke

Edited by heranke

Recommended SEO Addons:

Most Important: Header Tags SEO - Ultimate SEO V 2.2d

Recommended Addons:

Also Purchased (AP) Preselection - Contribution 3294

Share this post


Link to post
Share on other sites

The association is stored in the products_to_documents table in the database. You could add a language_id field to that table to store the language. You can use tep_draw_pull_down_menu() and fill it with the languages for the input. See the languages box for the exact code to use.

 

I'm really busy fixing sites that USPS broke with their current update, so my time is limited right now, but I'll help as much as I can.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hi Jim,

 

I've just changed Documents manager to work with 2.3.

 

Everything works fine except for one thing.

 

The delete function for 'Document types' with files attached to them doesn't work. If I try to delete a Document type with files attached to it, I get the following message:

 

Warning: unlink(E:/xampp/htdocs/document_manager/catalog/documents/brochures): No such file or directory in E:\xampp\htdocs\document_manager\catalog\admin\includes\functions\general.php on line 1127

 

Fatal error: Cannot use object of type mysqli_result as array in E:\xampp\htdocs\document_manager\catalog\admin\documents.php on line 121

 

Deleting empty Document types works and

Deleting files in a Document type works perfectly.

 

This is the part of the code from admin\documents.php including line 121

 

// Delete a document type
case 'process_delete_type':
if (isset ($_POST['type_name']) && $_POST['type_name'] != '') {
tep_remove (DIR_FS_CATALOG_DOCUMENTS . $_POST['type_name']);
}

if (isset ($_POST['document_types_id']) && $_POST['document_types_id'] > 0) {
$document_types_id = (int) $_POST['document_types_id'];
$products_query_raw = "
select
documents_id
from
" . TABLE_DOCUMENTS . "
where
document_types_id = " . $document_types_id . "
";
// print $products_query_raw . "
\n";
$products_query = tep_db_query ($products_query_raw);
while ($products_data = tep_db_fetch_array ($products_query)) {
tep_db_query ("delete from " . TABLE_PRODUCTS_TO_DOCUMENTS . "
where documents_id = '" . (int)$products_query['documents_id'] . "'
");
}

tep_db_query("delete from " . TABLE_DOCUMENTS . "
where document_types_id = '" . $document_types_id . "'
");
tep_db_query("delete from " . TABLE_DOCUMENT_TYPES . "
where document_types_id = '" . $document_types_id . "'
");
}

tep_redirect (tep_href_link (FILENAME_DOCUMENTS, tep_get_all_get_params (array ('action','dt') ) ) );
break;

 

Any ideas?

 

Thanks,

 

Gerhard


Addons installed on my website:

 

- Addons Installed

- Advanced Special Offer Discounts

- AJAX-Attribute Manager for osc 2.3.1

- Banner box v1.1.1

- Dutch Language Pack

- Extra Pages-info box with admin for OSC2.3

- German Language Pack

- Login Box

- Multi-language Support for Configuration

- Multiple products manager

- Order Editor

- OSC PDF Catalogue 2.1

- PDF-Datasheet

- product Field Groups

- Quickly Update Product Stock

- Unit of weight

- YAG (Yet another Guestbook)

Share this post


Link to post
Share on other sites

That's what I would expect. Most operating systems won't let you delete a directory that contains files. You could loop through the files and delete them one at a time, then delete the directory.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

I started to build a 2.3x version of the Document Manager a while back. It's not complete, but it may be good enough to use. If you're willing to help finish this, or at least report bugs so I can fix them, the package is available here.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

I started to build a 2.3x version of the Document Manager a while back. It's not complete, but it may be good enough to use. If you're willing to help finish this, or at least report bugs so I can fix them, the package is available here.

 

Regards

Jim

 

@@kymation

 

Hi Jim,

 

I am trying to use your updated version on 2.3.4BS and so far the only bug I have found is that the documents will not upload to the respective folder.

 

Also I need to add an option for category association if thats at all possible with the way the code stands.

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

Try removing the .htaccess file from the /documents directory. It's there for security, but some server setups seem to interfere with this.

 

The code is not designed to associate a document with a category. As a workaround, I create a hidden product in that category and associate the document with that. It will then show up in that category on the documents page, but not on any product page. If you need it to show up on all of the product pages, you will need to associate it with each product in that category.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Try removing the .htaccess file from the /documents directory. It's there for security, but some server setups seem to interfere with this.

 

The code is not designed to associate a document with a category. As a workaround, I create a hidden product in that category and associate the document with that. It will then show up in that category on the documents page, but not on any product page. If you need it to show up on all of the product pages, you will need to associate it with each product in that category.

 

Regards

Jim

 

@@kymation

 

Hi Jim,

 

I have been working on expanding the code to associate a document with a category.

 

So far the admin side works great. I have created a new table called documents_to_categories and duplicated the case code etc so now the document gets associated with a category.

 

The problem I have now is getting the download link to show on the category page because at the moment it shows nothing.

 

I have expanded the module code below but not sure if I need to either a) do more to show the link or B) modify the code in index.php to get it to work

 

Any thoughts would be appreciated.

<?php
/*
  $Id: documents.php, v1.0.1 200909014 kymation Exp $
  $Loc: catalog/includes/modules/ $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2009 osCommerce

  Released under the GNU General Public License
*/


// Generate a set of links to documents linked to this product
    $products_documents_query_raw = "
      select
        count(*) as total
      from
        " . TABLE_PRODUCTS_TO_DOCUMENTS . "
      where
        products_id = '" . (int) $_GET['products_id'] . "'
    ";
    $products_documents_query = tep_db_query ($products_documents_query_raw);
    $products_documents = tep_db_fetch_array ($products_documents_query);
    if ($products_documents['total'] > 0) {

?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td>
<?php

      $buttons_array = array();
      $products_documents_query_raw = "
        select
          d.documents_id,
          d.documents_name,
          d.documents_size,
          d.documents_title,
          dt.type_name,
          dt.type_description,
          d2c.documents_to_categories_id,
          d2c.categories_id,
          d2c.documents_id
        from " . TABLE_DOCUMENTS . " d,
             " . TABLE_DOCUMENT_TYPES . " dt,
             " . TABLE_PRODUCTS_TO_DOCUMENTS . " p2d,
             " . TABLE_DOCUMENTS_TO_CATEGORIES . " d2c,
        where p2d.products_id = '" . (int) $_GET['products_id'] . "'
          and d.documents_id = p2d.documents_id
          and dt.document_types_id = d.document_types_id       
          and d2c.documents_id = d.documents_id
          and d.documents_visible = 'True'
          and dt.type_visible = 'True'
        order by
          dt.sort_order,
          d.sort_order
      ";

      $products_documents_query = tep_db_query ($products_documents_query_raw);
      while ($products_documents = tep_db_fetch_array ($products_documents_query) ) {
        // Separate the document name and the extension from the filename
        $documents_name = $products_documents['documents_name'];
        $filename_parts = pathinfo ($documents_name);
        $documents_name = $filename_parts['filename'];
        $documents_extension = $filename_parts['extension'];

        // Get the document information from the extension
        $document_type_array = tep_get_document_type ($documents_extension);

        echo '<span class="document_type">' . $products_documents['type_description'] . ':</span> ';
        echo '<span class="document"><a href="' . tep_href_link (DIR_WS_DOCUMENTS . $products_documents['type_name'] . '/' . $products_documents['documents_name']) . '" target="_new">';
        echo $products_documents['documents_title'];
        echo ' [' . number_format ($products_documents['documents_size']) . ' k]';
        echo ' ' . $document_type_array['icon'];
        echo '</a></span><br>';

      } // while ($products_documents
    } // if ($products_documents

?>
        </td>
      </tr>
Edited by PupStar

Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

That module was designed to show up only on the product page, so you would need to modify it. I would instead make a new module for the index page and write it to show the documents for the current category. Also, the above module was written before the existence of content modules, so I would write the new module as a content module. You'll need to modify index.php to show the modules in any case.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×