post()

Post all Journals (and therefore Postings) for this Invoice

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2013-03-19
551421
public function post()
    {
        $this->setPostedAt(new \DateTime());

        foreach ($this->getJournals() as $journal) {
            $journal->post();
        }
    }
850169
def _post(self, url, params, uploads=None):
        
        self._call(self.POST, url, params, uploads)
1321031
public function actionPost($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $thread = Thread::find()->where([
                'id' => $tid,
                'category_id' => $cid,
                'forum_id' => $fid
            ])->limit(1)->one();
        if (empty($thread)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the thread you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $thread->forum->category->id,
                'fid' => $thread->forum->id,
                'id' => $thread->id,
                'slug' => $thread->slug
            ]);
        }

        if (!User::can(Rbac::PERM_CREATE_POST)) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $model = new Post();
        $model->subscribe = 1;
        $postData = Yii::$app->request->post();
        $replyFor = null;
        if (is_numeric($pid) && $pid > 0) {
            $replyFor = Post::find()->where(['id' => $pid])->limit(1)->one();
            if ($replyFor) {
                $model->content = Helper::prepareQuote($replyFor, Yii::$app->request->post('quote'));
            }
        }

        $preview = false;
        $previous = Post::find()->where(['thread_id' => $thread->id])->orderBy(['id' => SORT_DESC])->limit(1)->one();
        if ($model->load($postData)) {
            $model->thread_id = $thread->id;
            $model->forum_id = $thread->forum->id;
            $model->author_id = User::loggedId();
            if ($model->validate()) {
                if (isset($postData['preview-button'])) {
                    $preview = true;
                } else {
                    if ($model->podiumNew($previous)) {
                        $this->success(Yii::t('podium/flash', 'New reply has been added.'));
                        if (!empty($previous) && $previous->author_id == User::loggedId() && $this->module->podiumConfig->get('merge_posts')) {
                            return $this->redirect(['forum/show', 'id' => $previous->id]);
                        }
                        return $this->redirect(['forum/show', 'id' => $model->id]);
                    }
                    $this->error(Yii::t('podium/flash', 'Sorry! There was an error while adding the reply. Contact administrator about this problem.'));
                }
            }
        }
        return $this->render('post', [
            'replyFor' => $replyFor,
            'preview' => $preview,
            'model' => $model,
            'thread' => $thread,
            'previous' => $previous,
        ]);
    }
812131
public function setPostingFeeInvoice(\HarvestCloud\CoreBundle\Entity\Invoice\PostingFeeInvoice $postingFeeInvoice = null)
    {
        $this->postingFeeInvoice = $postingFeeInvoice;

        return $this;
    }
546215
public function editAction(Request $request, Journal $journal)
    {
        // Let's add a blank posting
        $journal->addPosting(
            $this->get('phospr.posting_handler')->createPosting()
        );

        $form = $this->createForm('journal', $journal);
        $form->handleRequest($request);

        if ($form->isValid()) {
            try {
                foreach ($form->getData()->getPostings() as $posting) {
                    if (!$posting->getAccount()) {
                        $form->getData()->removePosting($posting);
                    }
                }

                $em = $this->get('doctrine')->getManager();
                $em->persist($form->getData());
                $em->flush();

                return $this->redirect($this->generateUrl(
                    'phospr_journal_show', array('id' => $journal->getId())
                ));
            } catch (JournalImbalanceException $e) {
                exit($e->getMessage());
            }
        }

        return array(
            'journal' => $journal,
            'form' => $form->createView(),
        );
    }
1310727
public function addPosting(PostingInterface $posting)
    {
        $this->postings->add($posting);
        $posting->setJournal($this);
    }
402774
public function save()
    {
        $data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/edit/', $this->serialize());
        $this->deserialize($data);
    }
1355147
public function post()
    {
        $this->setPostedAt(new \DateTime());

        $this->ensureZeroSumOfPostings();

        foreach ($this->getPostings() as $posting) {
            $posting->post();
        }
    }
1199239
public function active($per_page)
	{
		$per_page = is_numeric($per_page) ? $per_page : 5;

		return Post::with(array('tags', 'user'))
			->where('active', 1)
			->where('publish_date', '<=', new DateTime)
			->orderBy('publish_date', 'desc')
			->paginate($per_page);
	}
1267298
function ctc_get_posts() {

		// Get posts
		$posts = get_posts( array(
			'post_type'      	=> 'ctc_location',
			'orderby'        	=> $this->ctc_instance['orderby'],
			'order'          	=> $this->ctc_instance['order'],
			'numberposts'    	=> $this->ctc_instance['limit'],
			'suppress_filters'	=> false // keep WPML from showing posts from all languages: http://bit.ly/I1JIlV + http://bit.ly/1f9GZ7D
		) );

		// Return filtered
		return apply_filters( 'ctc_locations_widget_get_posts', $posts );

	}
582102
public function setDataFromPost() {
    // Recorremos el arreglo $data
    foreach ($this->data as $key => $value) {
      // Si existe la llave en $_POST entonces asignamos su valor
      // a $data
      if (isset($_POST[$key])) {
        $this->data[$key] = $_POST[$key];
      }
    }
  }
936450
public function edit()
    {
        if (!userHasPermission('admin:invoice:invoice:edit')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        $oUri   = Factory::service('Uri');
        $oInput = Factory::service('Input');

        $iInvoiceId            = (int) $oUri->segment(5);
        $oModel                = $this->oInvoiceModel;
        $this->data['invoice'] = $oModel->getById(
            $iInvoiceId,
            ['expand' => $oModel::EXPAND_ALL]
        );

        if (!$this->data['invoice'] || $this->data['invoice']->state->id != 'DRAFT') {
            show404();
        }

        // --------------------------------------------------------------------------

        //  Page Title
        $this->data['page']->title = 'Edit Invoice &rsaquo; ' . $this->data['invoice']->ref;

        // --------------------------------------------------------------------------

        if ($oInput->post()) {
            if ($this->validatePost()) {
                if ($oModel->update($this->data['invoice']->id, $this->getObjectFromPost())) {

                    //  Send invoice if needed
                    $oInvoice = $oModel->getById($this->data['invoice']->id);
                    $this->sendInvoice($oInvoice);

                    $oSession = Factory::service('Session', 'nails/module-auth');
                    $oSession->setFlashData('success', 'Invoice was saved successfully.');

                    redirect('admin/invoice/invoice/index');

                } else {
                    $this->data['error'] = 'Failed to update invoice. ' . $oModel->lastError();
                }
            } else {
                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Page data
        $aItemUnits = $this->oInvoiceItemModel->getUnits();
        $aTaxes     = $this->oTaxModel->getAll();

        $this->data['invoiceStates'] = $oModel->getSelectableStates();

        // --------------------------------------------------------------------------

        //  Invoice Items
        if ($oInput->post()) {

            $aItems = $oInput->post('items') ?: [];
            //  Tidy up post data as expected by JS
            foreach ($aItems as &$aItem) {

                $aItem['label'] = html_entity_decode($aItem['label'], ENT_QUOTES, 'UTF-8');
                $aItem['body']  = html_entity_decode($aItem['body'], ENT_QUOTES, 'UTF-8');

                $sUnitCost                     = $aItem['unit_cost'];
                $aItem['unit_cost']            = new \stdClass();
                $aItem['unit_cost']->formatted = new \stdClass();
                $aItem['unit_cost']->formatted = !empty($sUnitCost) ? $sUnitCost : null;

                $aItem['tax']     = new \stdClass();
                $aItem['tax']->id = !empty($aItem['tax_id']) ? (int) $aItem['tax_id'] : null;

                $sUnit             = !empty($aItem['unit']) ? $aItem['unit'] : null;
                $aItem['unit']     = new \stdClass();
                $aItem['unit']->id = $sUnit;
            }

        } else {
            $aItems = $this->data['invoice']->items->data;
        }

        // --------------------------------------------------------------------------

        $oCurrency                = Factory::service('Currency', 'nails/module-currency');
        $aCurrencies              = $oCurrency->getAllEnabled();
        $this->data['currencies'] = $aCurrencies;
        //  A customer ID can be specified when creating an invoice; this prevents undefined var errors
        $this->data['customer_id'] = null;

        // --------------------------------------------------------------------------

        $oAsset = Factory::service('Asset');
        //  @todo (Pablo - 2018-11-30) - Load the minified version once the JS bundling has been sorted
        $oAsset->load('invoice.edit.js', 'nails/module-invoice');
        $oAsset->inline(
            'ko.applyBindings(
                new invoiceEdit(
                    ' . json_encode($aItemUnits) . ',
                    ' . json_encode($aTaxes) . ',
                    ' . json_encode($aItems) . ',
                    ' . json_encode($aCurrencies) . '
                )
            );',
            'JS'
        );

        //  Load views
        Helper::loadView('edit');
    }
11759
public function posted($method = 'post')
    {
        $postIndicator = $this->getPostIndicator();

        if ($postIndicator->posted($method)) {
            if ($method == 'post') {
                $this->setValues($_POST, $_FILES);
            } else if ($method == 'get') {
                $this->setValues($_GET);
            }
            return true;
        }

        return false;
    }
912405
def post(ctx, odm):
    """"""
    try:
        ctx.obj['RWS'].send_request(PostDataRequest(odm.read()))
        if ctx.obj['RAW']:
            click.echo(ctx.obj['RWS'].last_result.text)
    except RWSException as e:
        click.echo(e.message)
2609
protected function submitAddReview()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('review');
        $this->addReview();
    }
158995
protected function count_posts() {
		global $wpdb;

		$query = $this->get_count_query();

		$this->total_posts = $wpdb->get_var( $query );
	}
120068
public function posts()
    {
        $withTrashed = config('forum.preferences.display_trashed_posts') || Gate::allows('viewTrashedPosts');
        $query = $this->hasMany(Post::class);
        return $withTrashed ? $query->withTrashed() : $query;
    }